public function create() { if (isset($_POST['purid']) && !empty($_POST['purdate']) && !empty($_POST['vendid'])) { $newPurchase = new Purchase(); $newPurchase->pur_id = $_POST['purid']; $newPurchase->ord_no = $_POST['odrno']; $newPurchase->vend_id = $_POST['vendid']; $newPurchase->pur_amount; $newPurchase->pur_discount; $newPurchase->pur_total; $newPurchase->pur_comment; $newPurchase->pur_datecreated; if ($newPurchase->create()) { return 1; } else { return 2; } } }
private function addOrUpdatePurchases($id, $postedData){ try{ try{ $data = \Purchase::find($id); }catch (\ActiveRecord\RecordNotFound $ex) { $data = null; } $attributes = $this->getAttrForPurchaesFromPost($postedData, $data); $rolproducts = array(); if(is_null($data)){ $data = \Purchase::create($attributes); }else{ $data->update_attributes($attributes); } $this->addorupdatePurchaseLineItems($data, $postedData, $rolproducts); if(count($rolproducts)>0 && $this->mail_for_rols){ $this->prepareMailForROLAlert($rolproducts); } } catch (\Slim\Exception $ex) { $rtnmsg = "Error"; } catch (\Exception $ex) { $rtnmsg = "Error"; } return $rtnmsg; }