About Inventory Volume

Source: Internet
Author: User

1  Public functionGoods_number ()2     {3         //Receive item ID4         $id= I (' get.id ');5         $gnModel= D (' Goods_number ');6         7         //working with Forms8         if(is_post)9         {
Var_dump ($_post) die;Ten //Delete original inventory first One $gnModel->where (Array( A' goods_id ' =Array(' eq ',$id), -)),Delete (); - //var_dump ($_post);d ie; the $gaid= I (' post.goods_attr_id '); - $GN= I (' Post.goods_number '); - //calculate the ratio of the commodity attribute ID and the stock quantity first - $gaidCount=Count($gaid); + $gnCount=Count($GN); - $rate=$gaidCount/$gnCount; + //Cycle Stock Volume A $_i= 0;//take the first few commodity attribute IDs at foreach($GN as $k=$v) - { - $_goodsattrid=Array();//Put the ID that's taken down here. - ///Then take $rate from the array of commodity attribute IDs, loop one at a time - for($i= 0;$i<$rate;$i++) - { in $_goodsattrid[] =$gaid[$_i]; - $_i++; to } + //First Order Ascending - Sort($_goodsattrid, sort_numeric);//sort in a numeric form the //Convert the extracted product attribute ID into a string * $_goodsattrid= (string)implode(‘,‘,$_goodsattrid); $ $gnModel->add (Array(Panax Notoginseng' goods_id ' =$id, -' goods_attr_id ' =$_goodsattrid, the' Goods_number ' =$v, + )); A } the $this->success (' Setup succeeded! ', U (' goods_number?id= '. I (' Get.id '))); + Exit; - } $ $ //Take out this item by Product ID value of all optional attributes - $gaModel= D (' goods_attr '); - $gaData=$gaModel->alias (' a ') the->field (' A.*,b.attr_name ') --Join(' left JOIN __attribute__ b on A.attr_id=b.id ')Wuyi->where (Array( the' a.goods_id ' =Array(' eq ',$id), -' B.attr_type ' =Array(' eq ', ' optional '), Wu)),Select (); - //process This two-dimensional array: Convert to three-dimensional: put the same attributes together About $_gadata=Array(); $ foreach($gaData as $k=$v) - { - $_gadata[$v[' Attr_name '] [] =$v; - } A + //first take out the inventory that has been set up for this product the $gnData=$gnModel->where (Array( -' goods_id ' =$id, $)),Select (); the //Var_dump ($gnData); the the $this->assign (Array( the' Gadata ' =$_gadata, -' Gndata ' =$gnData, in )); the the //Setting page Information About $this->assign (Array( the' _page_title ' = ' inventory ', the' _page_btn_name ' = ' return list ', the' _page_btn_link ' + U (' lst '), + )); - //1. Display the form the $this-display ();Bayi}

About Inventory Volume

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.