private function insertSampleRecord() { $rawPostedData = array("shippingAddress" => array("shipping_address_street" => "#018 Gaddang Street Barangay Quirino", "shipping_address_city" => "Solano", "shipping_address_province" => "Nueva Vizcaya", "shipping_address_country" => "Philippines"), "orderInformation" => array("notes" => "this is a random note . heres a proof . " . uniqid(), "invoice_number" => uniqid(), "sales_person" => "Marcials Furniture", "ship_date" => "November 25,2015", "order_date" => "November 23,2015", "ordered_products" => array(array("product_name" => "wooden chair 2x", "description" => "a wooden chair made of wood", "quantity" => 10, "unit_price" => 3000, "line_total" => 30000), array("product_name" => "wooden chair 3x", "description" => "a wooden chair made of wood but with color", "quantity" => 20, "unit_price" => 4000, "line_total" => 80000), array("product_name" => "Banana Chair", "description" => "A chair that is shaped like a banana", "quantity" => 10, "unit_price" => 3000, "line_total" => 30000)), "sub_total" => 140000, "tax" => 0.5, "shipping" => 2, "total" => 140702, "paid" => 141000, "change" => 298), "customerModel" => array("title" => "Mr", "firstname" => "john " . Customer::model()->count(), "middlename" => "middle " . Customer::model()->count(), "lastname" => "doe " . Customer::model()->count(), "contact_number" => "09069148369")); $this->totalPaid += 141000; $invoiceDataPersistor = new InvoiceDataPersistor($rawPostedData); $invoiceDataPersistor->save(); return $invoiceDataPersistor; }
public function actionSave() { header("Content-Type: application/json"); $jsonResult = array("status" => "", "message" => ""); $rawPostedData = file_get_contents("php://input"); $_POST = json_decode($rawPostedData, true); $persistorObj = new InvoiceDataPersistor($_POST); try { $persistorObj->save(); $jsonResult = array("status" => "success", "message" => "Invoice created"); } catch (Exception $e) { $jsonResult = array("status" => "failed", "message" => $e->getMessage()); } echo json_encode($jsonResult); }