public function SelectItem() { $db = $this->getAdapter(); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $db = new Application_Model_DbTable_DbGlobal(); $productSql = "SELECT\n\t\t\t\tp.pro_id\n\t\t\t\t,p.item_name\n\t\t\t\t,p.item_code\n\t\t\t\t,(SELECT g.Name FROM tb_category AS g WHERE g.CategoryId = (SELECT cate_id FROM tb_product WHERE pro_id = pl.`pro_id` LIMIT 1)) AS Cate_name\n\t\t\t\t,(SELECT b.Name FROM tb_branch AS b WHERE b.branch_id = (SELECT brand_id FROM tb_product WHERE pro_id = pl.`pro_id` LIMIT 1 )) AS Branch\n\t\t\t\t,(SELECT lo.Name FROM tb_sublocation AS lo WHERE lo.LocationId = pl.LocationId LIMIT 1) AS LocationName\n\t\t\t\t,pl.qty\n\t\t\tFROM tb_prolocation AS pl,tb_product AS p WHERE pl.`pro_id`=p.pro_id "; $str_condition = " AND pl.LocationId"; $productSql .= $db->getAccessPermission($result["level"], $str_condition, $result["location_id"]); if ($this->getRequest()->isPost()) { $post = $this->getRequest()->getPost(); $productName = $this->getRequest()->getParam('s_name'); if ($post['LocationId'] !== '' and $post['LocationId'] != 0) { $productSql .= " AND pl.LocationId = " . trim($post['LocationId']); } if ($post['p_name'] != '') { $productSql .= " AND p.item_name LIKE '%" . trim($post['p_name']) . "%'"; $productSql .= " OR p.item_code LIKE '%" . trim($post['p_name']) . "%'"; } if ($post['category_id'] !== '' and $post['category_id'] != 0) { //echo $post['category_id']; exit(); $productSql .= " AND p.cate_id =" . trim($post['category_id']); } if ($post['branch_id'] !== '' and $post['branch_id'] != 0) { $productSql .= " AND p.brand_id =" . trim($post['branch_id']); } } //echo $productSql;exit(); $productSql .= " ORDER BY p.item_name,p.cate_id DESC"; return $rows = $db_rs->fetchAll($productSql); }
public function indexAction() { $formFilter = new Product_Form_FrmProductFilter(); $this->view->formFilter = $formFilter; //$cate = $formFilter->listCategory(); //$this->view->cate = $cate; $list = new Application_Form_Frmlist(); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $db = new Application_Model_DbTable_DbGlobal(); // $productSql = "SELECT p.pro_id,p.item_name,p.item_code,g.Name As cate_name, b.Name as LocationName, lo.Name, pl.qty // FROM tb_product AS p // INNER JOIN tb_prolocation AS pl ON pl.pro_id = p.pro_id // INNER JOIN tb_category AS g ON g.CategoryId = p.cate_id // INNER JOIN tb_branch as b ON b.branch_id = p.brand_id // INNER JOIN tb_sublocation AS lo ON lo.LocationId = pl.LocationId WHERE 1 "; $productSql = "SELECT \n\t\t\t\tp.pro_id \n\t\t\t\t,p.item_name\n\t\t\t\t,p.item_code\n\t\t\t\t,(SELECT g.Name FROM tb_category AS g WHERE g.CategoryId = (SELECT cate_id FROM tb_product WHERE pro_id = pl.`pro_id` LIMIT 1)) AS Cate_name\n\t\t\t\t,(SELECT b.Name FROM tb_branch AS b WHERE b.branch_id = (SELECT brand_id FROM tb_product WHERE pro_id = pl.`pro_id` LIMIT 1 )) AS Branch\n\t\t\t\t,(SELECT lo.Name FROM tb_sublocation AS lo WHERE lo.LocationId = pl.LocationId LIMIT 1) AS LocationName\n\t\t\t\t,pl.qty\n\t\t\tFROM tb_prolocation AS pl,tb_product AS p WHERE pl.`pro_id`=p.pro_id "; $str_condition = " AND pl.LocationId"; $productSql .= $db->getAccessPermission($result["level"], $str_condition, $result["location_id"]); if ($this->getRequest()->isPost()) { $post = $this->getRequest()->getPost(); $productName = $this->getRequest()->getParam('s_name'); if ($post['LocationId'] !== '' and $post['LocationId'] != 0) { $productSql .= " AND pl.LocationId = " . trim($post['LocationId']); } if ($post['p_name'] != '') { $productSql .= " AND p.item_name LIKE '%" . trim($post['p_name']) . "%'"; $productSql .= " OR p.item_code LIKE '%" . trim($post['p_name']) . "%'"; } if ($post['category_id'] !== '' and $post['category_id'] != 0) { //echo $post['category_id']; exit(); $productSql .= " AND p.cate_id =" . trim($post['category_id']); } if ($post['branch_id'] !== '' and $post['branch_id'] != 0) { $productSql .= " AND p.brand_id =" . trim($post['branch_id']); } } //echo $productSql;exit(); $productSql .= " ORDER BY p.item_name,p.cate_id DESC"; $rows = $db->getGlobalDb($productSql); $link = array('module' => 'product', 'controller' => 'index', 'action' => 'update'); $columns = array("ITEM_NAME_CAP", "item_code", "CATEGORY_CAP", "BRAND_CAP", "LOCATION_NAME_CAP", "QTY_HAND_CAP"); $urlEdit = BASE_URL . "/distributor/index/update"; $urlEdit = BASE_URL . "/product/index/update"; $this->view->list = $list->getCheckList(1, $columns, $rows, array('item_name' => $link), $urlEdit); Application_Model_Decorator::removeAllDecorator($formFilter); }
protected function GetuserInfoAction() { $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); return $result; }
public function getTypePriceOption() { $db = $this->getAdapter(); $sql = 'SELECT type_id, price_type_name FROM tb_price_type WHERE public = 1 AND price_type_name!=""'; $rows = $db->fetchAll($sql); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $option = ""; if (!empty($rows)) { foreach ($rows as $price) { $option .= '<option value="' . $price['type_id'] . '" label="' . htmlspecialchars($price['price_type_name'], ENT_QUOTES) . '">' . htmlspecialchars($price['price_type_name'], ENT_QUOTES) . '</option>'; } } if ($result["level"] == 1 or $result["level"] == 2) { $option .= '<option value="-1" label="Add Price Type">Add Price Type</option>'; } return $option; }
public function productOrder($data = null) { //Application_Form_FrmLanguages::getCurrentlanguage(); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $tr = Application_Form_FrmLanguages::getCurrentlanguage(); $request = Zend_Controller_Front::getInstance()->getRequest(); $db = new Application_Model_DbTable_DbGlobal(); $paymentElement = new Zend_Form_Element_Submit('payment'); $paymentElement->setAttribs(array('Phone' => 'Phone')); $this->addElement($paymentElement); $rs = $db->getGlobalDb('SELECT vendor_id, v_name FROM tb_vendor WHERE v_name!="" ORDER BY vendor_id DESC'); $customerValue = $request->getParam('vendor_id'); $options = array('' => $tr->translate('Please_Select'), '-1' => $tr->translate('Add_New_Vendor')); if (!empty($rs)) { foreach ($rs as $read) { $options[$read['vendor_id']] = $read['v_name']; } } $vendor_id = new Zend_Form_Element_Select('v_name'); $vendor_id->setAttribs(array('class' => 'validate[required]', 'Onchange' => 'getCustomerInfo()')); $vendor_id->setMultiOptions($options); //$customerID->setattribs(array(id'=>'customer_id','onchange'=>'this.form.submit()',)); $vendor_id->setValue($customerValue); $this->addElement($vendor_id); // $rowsCategory= $db->getGlobalDb('SELECT CategoryId, Name FROM tb_category ORDER BY CategoryId DESC '); // $options = ""; // if($result["level"]==1 OR $result["level"]==2){ // $options = array("1"=>"Defaul Catogory","-1"=>"Add New Category"); // } // if($rowsCategory) { // foreach($rowsCategory as $readCategory) $options[$readCategory['CategoryId']]=$readCategory['Name']; // } // $categoryElement = new Zend_Form_Element_Select('category'); // $categoryElement->setAttribs(array('class' => 'validate[required] demo-code-language',"Onchange"=>"showPopupCategory()")); // $categoryElement->setMultiOptions($options); // $this->addElement($categoryElement); $roder_element = new Zend_Form_Element_Text("txt_order"); $roder_element->setAttribs(array('placeholder' => 'Optional', "onblur" => "CheckPOInvoice();")); $this->addElement($roder_element); $contactElement = new Zend_Form_Element_Text('contact'); $contactElement->setAttribs(array('placeholder' => 'Enter Contact Name')); $this->addElement($contactElement); $orderElement = new Zend_Form_Element_Text('order'); $orderElement->setAttribs(array('placeholder' => 'Enter Order')); $this->addElement($orderElement); $phoneElement = new Zend_Form_Element_Text('txt_phone'); $phoneElement->setAttribs(array('placeholder' => 'Enter Phone Number')); $this->addElement($phoneElement); // $option_loc = 'SELECT LocationId, Name FROM tb_sublocation WHERE Name!="" '; // if($result['level']!=1 || $result['level']!=2){//if this isn't super user or inventory manager // $option_loc .= " AND LocationId = ".$result['location_id'];//select only this user location // } // $option_loc .= ' ORDER BY LocationId DESC'; // $rs=$db->getGlobalDb($option_loc); // $productValue = $request->getParam('LocationId'); // $option =array(); // if($result['level']==1 || $result['level']==2){//if this is super user // $option =array("1"=>"Defaul Location","-1"=>"Add New Location"); // } // if(!empty($rs)) foreach($rs as $read) $option[$read['LocationId']]=$read['Name']; // $locationID=new Zend_Form_Element_Select('LocationId'); // $locationID->setMultiOptions($option); // $locationID->setattribs(array('id'=>'LocationId', // 'Onchange'=>'AddLocation()', // 'class'=>'demo-code-language' // )); // $locationID->setValue($productValue); // $this->addElement($locationID); $user = $this->GetuserInfo(); $options = ""; $sql = "SELECT LocationId, Name FROM tb_sublocation WHERE Name!='' "; if ($user["level"] == 1 or $user["level"] == 2) { $options = array("1" => $tr->translate("Please_Select"), "-1" => $tr->translate("ADD_NEW_LOCATION")); } else { $sql .= " AND LocationId = " . $user["location_id"]; } $sql .= " ORDER BY LocationId DESC"; $rs = $db->getGlobalDb($sql); $productValue = $request->getParam('LocationId'); if (!empty($rs)) { foreach ($rs as $read) { $options[$read['LocationId']] = $read['Name']; } } $locationID = new Zend_Form_Element_Select('LocationId'); $locationID->setAttribs(array('class' => 'validate[required]')); $locationID->setMultiOptions($options); $locationID->setattribs(array('id' => 'LocationId', 'Onchange' => 'AddLocation()')); $locationID->setValue($productValue); $this->addElement($locationID); $rowspayment = $db->getGlobalDb('SELECT * FROM tb_paymentmethod'); if ($rowspayment) { foreach ($rowspayment as $readCategory) { $options_cg[$readCategory['payment_typeId']] = $readCategory['payment_name']; } } $paymentmethodElement = new Zend_Form_Element_Select('payment_name'); $paymentmethodElement->setMultiOptions($options_cg); $this->addElement($paymentmethodElement); $rowsPayment = $db->getGlobalDb('SELECT CurrencyId, Description,Symbol FROM tb_currency'); if ($rowsPayment) { foreach ($rowsPayment as $readPayment) { $options_cur[$readPayment['CurrencyId']] = $readPayment['Description'] . $readPayment['Symbol']; } } $currencyElement = new Zend_Form_Element_Select('currency'); $currencyElement->setAttribs(array('class' => 'demo-code-language')); $currencyElement->setMultiOptions($options_cur); $this->addElement($currencyElement); $descriptionElement = new Zend_Form_Element_Textarea('remark'); $this->addElement($descriptionElement); $remarkaddElement = new Zend_Form_Element_Textarea('remark_add'); $this->addElement($remarkaddElement); $vendoraddElement = new Zend_Form_Element_Textarea('vendor_address'); $vendoraddElement->setAttribs(array('placeholder' => 'Enter Vendor Address')); $this->addElement($vendoraddElement); $allTotalElement = new Zend_Form_Element_Text('all_total'); $allTotalElement->setAttribs(array('readonly' => 'readonly')); $this->addElement($allTotalElement); $discountTypeElement = new Zend_Form_Element_Radio('discount_type'); $discountTypeElement->setMultiOptions(array(1 => '%', 2 => 'Fix Value')); $discountTypeElement->setAttribs(array('checked' => 'checked')); $discountTypeElement->setAttribs(array('onChange' => 'doTotal()')); $this->addElement($discountTypeElement); // $isFreeTypeElement = new Zend_Form_Element_Checkbox('pricefree_'); // //$isFreeTypeElement->setMultiOptions(array(1=>'%',2=>'Fix Value')); // $isFreeTypeElement->options(array('setCheckedValue'=>1,'setUncheckedValue'=>0)); // $isFreeTypeElement->setAttribs(array('onChange'=>'getPriceFree()',)); // $this->addElement($isFreeTypeElement); $netTotalElement = new Zend_Form_Element_Text('net_total'); $netTotalElement->setAttribs(array('readonly' => 'readonly')); $this->addElement($netTotalElement); $discountValueElement = new Zend_Form_Element_Text('discount_value'); $discountValueElement->setAttribs(array('class' => 'input100px', 'onblur' => 'doTotal()')); $this->addElement($discountValueElement); $discountRealElement = new Zend_Form_Element_Text('discount_real'); $discountRealElement->setAttribs(array('readonly' => 'readonly', 'class' => 'input100px')); $this->addElement($discountRealElement); $globalRealElement = new Zend_Form_Element_Hidden('global_disc'); $this->addElement($globalRealElement); $discountValueElement = new Zend_Form_Element_Text('discount_value'); $discountValueElement->setAttribs(array('class' => 'input100px', 'onblur' => 'doTotal()')); $this->addElement($discountValueElement); $dis_valueElement = new Zend_Form_Element_Text('dis_value'); $dis_valueElement->setAttribs(array('placeholder' => 'Discount Value')); $dis_valueElement->setAttribs(array('onblur' => 'doTotal()')); $this->addElement($dis_valueElement); $totalAmountElement = new Zend_Form_Element_Text('totalAmoun'); $totalAmountElement->setAttribs(array('readonly' => 'readonly')); $this->addElement($totalAmountElement); $remainlElement = new Zend_Form_Element_Text('remain'); //$remainlElement->setAttribs(array('readonly'=>'readonly',)); $this->addElement($remainlElement); $balancelElement = new Zend_Form_Element_Text('balance'); //$remainlElement->setAttribs(array('readonly'=>'readonly',)); $this->addElement($balancelElement); $statusElement = new Zend_Form_Element_Select('status'); $opt_status = array("" => "Please Select status", 2 => 'Open', 3 => 'In Progress', 4 => 'Paid', 5 => "Recieved", 6 => 'Cancel'); $statusElement->setAttribs(array('class' => 'validate[required]', 'onchange' => 'calculatePrice();')); $statusElement->setMultiOptions($opt_status); // $statusElement->setAttribs(array('1'=>'Active',)); // $statusElement->setValue("Open"); $this->addElement($statusElement); $date_inElement = new Zend_Form_Element_Text('date_in'); $date = new Zend_Date(); $date_inElement->setAttribs(array('class' => 'validate[required]')); $date_inElement->setValue($date->get('YYYY-MM-dd')); $this->addElement($date_inElement); $dateOrderElement = new Zend_Form_Element_Text('order_date'); $dateOrderElement->setAttribs(array('class' => 'validate[required]', 'placeholder' => 'Click to Choose Date')); $dateOrderElement->setValue($date->get('YYYY-MM-dd')); $this->addElement($dateOrderElement); $addressElement = new Zend_Form_Element_Text('address'); $this->addElement($addressElement); $termElement = new Zend_Form_Element_Text('term'); $termElement->setAttribs(array('class' => 'validate[required]')); $this->addElement($termElement); // $branchElement = new Zend_Form_Element_Text('branch'); // $branchElement->setAttribs(array('class'=>'validate[required]',)); // $this->addElement($branchElement); $orderidElement = new Zend_Form_Element_Text('orderid'); $this->addElement($orderidElement); // $dateElement = new Zend_Form_Element_Text('date'); // $this->addElement($dateElement); $dateElement = new Zend_Form_Element_Text('date'); $this->addElement($dateElement); $paid_date = new Zend_Form_Element_Text("paid_date_payment"); $paid_date->setAttribs(array('class' => 'validate[required]')); $paid_date->setValue($date->get('YYYY-MM-dd')); $this->addElement($paid_date); // $receive_dateElement = new Zend_Form_Element_Text('recive_date'); // $this->addElement($receive_dateElement); // $reqDateElement = new Zend_Form_Element_Text('rs-date'); // $this->addElement($reqDateElement); $remarkElement = new Zend_Form_Element_Textarea('remark'); $this->addElement($remarkElement); $totalElement = new Zend_Form_Element_Text('total'); $this->addElement($totalElement); $paidElement = new Zend_Form_Element_Text('paid'); $paidElement->setAttribs(array('class' => 'custom[number]', 'Onblur' => 'doRemain()')); $this->addElement($paidElement); $history_idElement = new Zend_Form_Element_Hidden('history_id'); $this->addElement($history_idElement); $history_date_idElement = new Zend_Form_Element_Hidden('old_history_date'); $this->addElement($history_date_idElement); //$abcElement->setValue($value); Application_Form_DateTimePicker::addDateField(array('order_date', 'date_in', 'offer_date', 'receiv_date', 'paid_date_payment')); if ($data != null) { $idElement = new Zend_Form_Element_Text('id'); $this->addElement($idElement); $history_idElement->setValue($data["history_id"]); $history_date_idElement->setValue($data["date"]); $recieve_id = new Zend_Form_Element_Hidden("recieve_id"); $this->addElement($recieve_id); $recieve_id->setValue($data["recieve_id"]); $oldlocationIdElement = new Zend_Form_Element_Text('old_location'); $this->addElement($oldlocationIdElement); $idElement->setValue($data["order_id"]); $date_inElement->setValue($data["date_in"]); $oldStatusElement = new Zend_Form_Element_Hidden('oldStatus'); $this->addElement($oldStatusElement); $vendor_id->setValue($data["vendor_id"]); $contactElement->setValue($data['contact_name']); $phoneElement->setValue($data['phone']); $remarkaddElement->setValue($data['add_name']); if ($data["status"] == 1) { $statusElement->setValue("Quote"); } elseif ($data["status"] == 2) { $statusElement->setValue("Open"); } elseif ($data["status"] == 3) { $statusElement->setValue("In Progress"); } elseif ($data["status"] == 4) { $statusElement->setValue("Paid"); } elseif ($data["status"] == 5) { $statusElement->setValue("Recieved"); } else { $statusElement->setValue("Cancel"); } //$idElement->setValue($data['id']); $statusElement->setValue($data["status"]); $oldStatusElement->setValue($data['status']); $locationID->setvalue($data['LocationId']); $oldlocationIdElement->setvalue($data['LocationId']); $dateOrderElement->setValue($data["date_order"]); $roder_element->setValue($data['order']); $roder_element->setAttribs(array('readonly' => 'readonly')); $paymentmethodElement->setValue($data['payment_method']); $currencyElement->setValue($data['currency_id']); $remarkElement->setValue($data["remark"]); $paidElement->setValue($data['paid']); $totalAmountElement->setValue($data["all_total"]); //$remainlElement->setvalue($data['balance']); $allTotalElement->setValue($data['all_total']); $discountValueElement->setValue($data['discount_value']); $netTotalElement->setValue($data['net_total']); $balancelElement->setValue($data["balance"]); $globalRealElement->setValue($data["discount_real"]); } else { $discountTypeElement->setValue(1); } return $this; }
public function AddProductForm($data = null) { $tr = Application_Form_FrmLanguages::getCurrentlanguage(); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $db = new Application_Model_DbTable_DbGlobal(); $tr = Application_Form_FrmLanguages::getCurrentlanguage(); $nameElement = new Zend_Form_Element_Text('txt_name'); $nameElement->setAttribs(array('class' => 'validate[required]', 'placeholder' => $tr->translate('ENTER_ITEM'))); $this->addElement($nameElement); $product_size = new Zend_Form_Element_Text('product_size'); $product_size->setAttribs(array('placeholder' => $tr->translate('ENTER_ITME_SIZE'))); $this->addElement($product_size); $codeElement = new Zend_Form_Element_Text('txt_code'); $codeElement->setAttribs(array('placeholder' => $tr->translate("ENTER_ITEM_CODE"), 'class' => 'validate[required]', 'Onblur' => 'CheckPCode()')); $this->addElement($codeElement); $rowsBranch = $db->getGlobalDb('SELECT CategoryId, Name FROM tb_category WHERE Name!="" AND IsActive=1 ORDER BY CategoryId DESC '); $options = ""; if ($result["level"] == 1 or $result["level"] == 2) { $options = array("" => $tr->translate("SELECT_CATEGORY"), "-1" => $tr->translate("ADD_NEW")); } if ($rowsBranch) { foreach ($rowsBranch as $readCategory) { $options[$readCategory['CategoryId']] = $readCategory['Name']; } } $categoryElement = new Zend_Form_Element_Select('category'); $categoryElement->setAttribs(array('class' => 'validate[required]', "Onchange" => "showPopupCategory()")); $categoryElement->setMultiOptions($options); $this->addElement($categoryElement); $rowsBranch = $db->getGlobalDb('SELECT branch_id, Name FROM tb_branch WHERE Name!="" AND IsActive=1 ORDER BY Name DESC '); $options = ""; if ($result["level"] == 1 or $result["level"] == 2) { $options = array("" => $tr->translate("SELECT_BRAND"), "-1" => $tr->translate("ADD_NEW")); } if ($rowsBranch) { foreach ($rowsBranch as $readBranch) { $options[$readBranch['branch_id']] = $readBranch['Name']; } } $branchElement = new Zend_Form_Element_Select('branch_id'); $branchElement->setAttribs(array('class' => 'validate[required]', "Onchange" => "showPopupBranch()")); $branchElement->setMultiOptions($options); $this->addElement($branchElement); $typeElement = new Zend_Form_Element_Select('stock_type'); $typeElement->setAttribs(array('id' => 'single')); $typeElement->setMultiOptions(array(1 => $tr->translate("STOCKABLE"), 2 => $tr->translate("NON_STOCKED"), 3 => $tr->translate("SERVICE"))); $this->addElement($typeElement); $rowsmeasures = $db->getGlobalDb("SELECT id,measure_name FROM `tb_measure` WHERE measure_name!='' AND public =1"); $options = array("" => $tr->translate("SELECT_MEASURE"), "-1" => $tr->translate("ADD_NEW")); if ($rowsmeasures) { foreach ($rowsmeasures as $readmeasure) { $options[$readmeasure['id']] = $readmeasure['measure_name']; } } $measure_unit = new Zend_Form_Element_Select('measure_unit'); $measure_unit->setMultiOptions($options); $measure_unit->setAttribs(array('class' => 'validate[required]', "Onchange" => "showPopupMeasure()")); $measure_unit->setMultiOptions($options); $this->addElement($measure_unit); $uom = new Zend_Form_Element_Text('uom'); //uom = unit of measure $uom->setAttribs(array('class' => 'validate[custom[number]', "style" => "width:initial;", "size" => "4", 'readonly' => 'readonly')); $uom->setValue(1); $this->addElement($uom); $qty_perunit = new Zend_Form_Element_Text('qty_perunit'); //uom = unit of measure $qty_perunit->setAttribs(array('class' => 'validate[required[custom[number]]]', 'placeholder' => $tr->translate("QTY_PERUNIT"), "style" => "width:initial;", "size" => "4")); $this->addElement($qty_perunit); $label_perunit = new Zend_Form_Element_Text('label_perunit'); //uom = unit of measure $label_perunit->setAttribs(array('class' => 'validate[required]', 'placeholder' => $tr->translate("LABEL_UNIT"), "style" => "width:initial;", "size" => "10")); $this->addElement($label_perunit); $itemImageElement = new Zend_Form_Element_File('photo'); $this->addElement($itemImageElement); // $costingMethodElement = new Zend_Form_Element_Select('costingmethod'); // $costingMethodElement->setMultiOptions(array(1=>$tr->translate("Manual"), 2=>$tr->translate("Moving Average"),3=>$tr->translate("Last Purchase"))); // $this->addElement($costingMethodElement); $remarkElement = new Zend_Form_Element_Textarea('remark'); $this->addElement($remarkElement); $status = new Zend_Form_Element_Radio('status'); $status->setMultiOptions(array(1 => $tr->translate("ALL"), 2 => $tr->translate("IS_PURCHASE"), 3 => $tr->translate("IS_SALES"), 4 => $tr->translate("ALL_NONE"))); $status->setValue(1); $this->addElement($status); $rssetting = $db->getSetting(); $unit_sale_price = new Zend_Form_Element_Text('unit_sale_price'); if ($rssetting[0]['key_value'] == 1) { //if set default salse price $unit_sale_price = new Zend_Form_Element_Text('unit_sale_price'); $unit_sale_price->setLabel("Unit Sale Price"); $unit_sale_price->setAttribs(array('class' => 'validate[required[custom[number]]]')); } else { $unit_sale_price = new Zend_Form_Element_Hidden('unit_sale_price'); $unit_sale_price->setLabel(""); } $this->addElement($unit_sale_price); //echo $rs['key_valu']; if (!$data == null) { $idElement = new Zend_Form_Element_Hidden('id'); $this->addElement($idElement); $idElement->setValue($data['pro_id']); $itemImageElement->setValue($data['photo']); $codeElement->setValue($data['item_code']); $categoryElement->setValue($data['cate_id']); $branchElement->setValue($data['brand_id']); $measure_unit->setValue($data['measure_id']); $qty_perunit->setValue($data['qty_perunit']); $label_perunit->setValue($data['label']); $nameElement->setValue($data['item_name']); $typeElement->setValue($data['stock_type']); $remarkElement->setValue($data['remark']); $unit_sale_price->setValue($data['unit_sale_price']); } return $this; }
public function getProductOption() { $db = $this->getAdapter(); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $sql_cate = 'SELECT * FROM tb_pro_category'; $row_cate = $db->fetchAll($sql_cate); $user_info = new Application_Model_DbTable_DbGetUserInfo(); $result = $user_info->getUserInfo(); $option = '<option value="0" > - - - - - ជ្រើរើសផលិផល - - - - - </optgroup>'; foreach ($row_cate as $cate) { $option .= '<optgroup label="' . htmlspecialchars($cate['cat_name_en'] . " - " . $cate['cat_name_km'], ENT_QUOTES) . '">'; if ($result["level"] == 1 or $result["level"] == 2) { $sql = "SELECT pro_id,`name_kh`,`name_en`,item_code FROM tb_product WHERE `status` = 1 AND cate_id = " . $cate['cat_id'] . "\r\n\t\t\t\tAND `name_en`!='' ORDER BY last_mod_date DESC"; } else { $sql = "SELECT p.pro_id,p.name_kh,p.name_en,p.item_code FROM tb_product AS p\r\n\t\t\t\t\t\tINNER JOIN tb_prolocation AS pl ON p.pro_id = pl.pro_id\r\n\t\t\t\t WHERE p.status = 1 AND p.cate_id = " . $cate['cat_id'] . " ORDER BY p.last_mod_date DESC "; } $rows = $db->fetchAll($sql); if ($rows) { foreach ($rows as $value) { $option .= '<option value="' . $value['pro_id'] . '" label="' . htmlspecialchars($value['name_kh'] . " - " . $value['name_en'], ENT_QUOTES) . '">' . htmlspecialchars($value['name_kh'] . " - " . $value['name_en'], ENT_QUOTES) . " " . htmlspecialchars($value['item_code'], ENT_QUOTES) . '</option>'; } } $option .= "</optgroup>"; } if ($result["level"] == 1 or $result["level"] == 2) { $option .= '<option value="-1" label="Add New Product">Add New Product</option>'; } return $option; }