public function ajaxGetSupplierCowAction() { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $supplier_id = $this->_getParam('id'); $rowObj = new Mps_Model_RawProduct(); $subgroups = $rowObj->fetchRow("supplier_id = '{$supplier_id}' AND process_status = 'Incoming'"); if (false === $subgroups) { $arrResult = array("result" => 0); } else { $arrResult = array("result" => $subgroups->getId()); } echo Zend_Json::encode($arrResult); }
public function weighingAction() { $model = new Mps_Model_RawProduct(); $Pstatus = "Weighing"; $code = "fdCondumnStatus"; $model2 = new Base_Security_Privilege(); $arrValues = $model2->getCondumnValues($code); $arrSubcondumn = $model2->getCondumnValues('fdCondumnSubStatus'); $this->view->condumnValue = $arrValues; $this->view->condumnSubValue = $arrSubcondumn; $where = "p.id<>'-2147483648' and process_status='{$Pstatus}'"; //Edit cow weight values $request = $this->getRequest(); $options = $request->getPost(); $cowid = trim($this->_getParam('cowid')); $weight = trim($this->_getParam("weight")); $this->view->cowid = $cowid; if ($request->isPost()) { if (isset($options['submit'])) { //Update Cow weight $isExist = $model->isExist("id='{$cowid}' and process_status='{$Pstatus}'"); if ($isExist) { $model = $model->fetchRow("id='{$cowid}' and process_status='{$Pstatus}'"); if ($model !== false) { $model->setWeight($weight); $model->save(); } $this->_flashMessenger->addMessage(array('success' => 'Cow weight has been updated successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/mps/production/weighing/cowid/' . $cowid)); } else { $this->_flashMessenger->addMessage(array('error' => 'Cow ID does not exist!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/mps/production/weighing/cowid/' . $cowid)); } //End Update Cow weight } else { //Update condumn status and weight $condumnStatus = trim($this->_getParam("condumnStatus")); //get condumn id on the basis of condumn value while ($value = current($arrValues)) { if ($value == $condumnStatus) { $condumnID = key($arrValues); } next($arrValues); } $model = $model->fetchRow("id='{$cowid}' and process_status='{$Pstatus}'"); if ($model !== false && !empty($condumnID)) { $model->setWeight($weight); $model->setStatusOn($condumnID); $model->save(); $this->_flashMessenger->addMessage(array('success' => 'Condumn status has been updated successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/mps/production/weighing/cowid/' . $cowid)); } else { $this->_flashMessenger->addMessage(array('error' => 'Invalid Condumn status')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/mps/production/weighing/')); } //End Update condumn status and weight } } //End Edit /*---sorting ----*/ $order = trim($this->_getParam('order', "")); $col = trim($this->_getParam('col', "")); if ($order != "" && $col != "") { if ($col == "id") { $strOrderBy = "p.id {$order}"; } else { if ($col == "knocked_date") { $strOrderBy = "p.knocked_date {$order}"; } else { if ($col == "first_name") { $strOrderBy = array("s.first_name {$order}", "s.last_name {$order}"); } } } } else { $strOrderBy = "p.knocked_date desc"; //"p.knocked_date desc" } $this->view->sortOptions = array(); /*-----sorting----------*/ /*--search---*/ $this->view->linkArray = array(); $page_size = Zend_Registry::get('page_size'); $page = $this->_getParam('page', 1); $table = $model->getMapper()->getDbTable(); $select = $table->select()->setIntegrityCheck(false)->from(array("s" => 'supplier'), array("first_name", "last_name"))->join(array("p" => "raw_product"), "s.id=p.supplier_id and p.process_status='{$Pstatus}' and s.id!='-2147483648'", array("*"))->order($strOrderBy); // echo $sql = $select->__toString(); die; $paginator = Base_Paginator::factory($select); $paginator->setItemCountPerPage($page_size); $paginator->setCurrentPageNumber($page); $this->view->totalItems = $paginator->getTotalItemCount(); $this->view->paginator = $paginator; }
public function getids() { $obj = new Mps_Model_RawProduct(); $entries = $obj->fetchAll(); $arrUser = array(); foreach ($entries as $entry) { $arrUser[$entry->getId()] = $entry->getUsername(); } return $arrUser; }
public function ajaxGetSavePrintRawProductAction() { $request = $this->getRequest(); $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $Db = new Base_Db(); $transaction_nid = $Db->genCodeId('transaction_id'); $options = $request->getPost(); $options['transactionId'] = $transaction_nid; $options['status'] = 1; $i = 0; while ($options['num_cows']) { $options['sequenceNo'] = $Db->genCodeId('sequence_num'); $options['tagNo'] = $Db->genCodeId('tag_num'); $options['processStatus'] = 'Incoming'; $options['incomingDate'] = date("Y-m-d"); $model = new Mps_Model_RawProduct($options); $id = $model->save(); $options['num_cows']--; $i++; } echo Zend_Json::encode($id); }