views:

26

answers:

2

please help me with my simple cakephp application.

i have a products_warehouses table:

--
-- Table structure for table `products_warehouses`
--

CREATE TABLE IF NOT EXISTS `products_warehouses` (
  `id` int(5) NOT NULL auto_increment,
  `product_id` int(5) NOT NULL,
  `buyprice` decimal(8,2) NOT NULL,
  `sellprice` decimal(8,2) NOT NULL,
  `date_received` date NOT NULL,
  `total_stock_received` int(3) NOT NULL,
  `stock_on_hand` int(3) NOT NULL,
  `stock_to_transfer` int(3) default NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

what i want is, i have a transfer function so that when i transfer items. it would automatically go to products_showrooms table and the stock_to_tranfer field from warehouse would be added to the stock_received which is 0 in default from the products_showrooms table:

here is the products_showrooms table

--
-- Table structure for table `products_showrooms`
--

CREATE TABLE IF NOT EXISTS `products_showrooms` (
  `product_warehouse_id` int(5) NOT NULL,
  `stock_on_hand` int(2) NOT NULL,
  `stock_received` int(2) NOT NULL,
  `date_received` date NOT NULL,
  PRIMARY KEY  (`product_warehouse_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

can anyone help me with this?. should these tables have a relationship?.

can someone provide me with the right codes for a transfer() function?. what should i put in the models and controllers of these two tables?..

thank you.. please help me.

+1  A: 

First you will need to rename product_warehouse_id to products_warehouse_id. Then study relationship types from the cookbook. Try to put some effort in writing the code yourself and if you will not get it working then ask the question.

bancer
+1 for taking the time...
Leo
A: 

Read this: http://book.cakephp.org/

Leo