if (!is_object($d)) { echo "Return should be an object\n"; exit; } } $dept = product::join('user')->byId(5); if (count($dept->data) != 13) { echo "wrong props count " . count($dept->data) . "\n"; exit; } if ($db->count != 1) { echo "wrong count after byId\n"; exit; } // hasOne $products = product::get(); $cnt = 0; foreach ($products as $p) { if (get_class($d) != 'product') { echo "wrong class returned\n"; exit; } if (!$p->userId instanceof user) { echo "wrong return class of hasOne result\n"; exit; } $cnt++; } if ($cnt != $db->count && $cnt != 5) { echo "wrong count after get\n"; exit;
<?php //stop the direct browsing to this file - let index.php handle which files get displayed checkLogin(); $SI_SYSTEM_DEFAULTS = new SimpleInvoices_Db_Table_SystemDefaults(); $SI_TAX = new SimpleInvoices_Db_Table_Tax(); #get the invoice id $expense_id = $_GET['id']; $expense = expense::get($expense_id); $detail = expense::detail(); $detail['customer'] = customer::get($expense['customer_id']); $detail['biller'] = biller::select($expense['biller_id']); $detail['invoice'] = invoice::select($expense['invoice_id']); $detail['product'] = product::get($expense['product_id']); $detail['expense_account'] = expenseaccount::select($expense['expense_account_id']); $detail['expense_tax'] = expensetax::get_all($expense_id); $detail['expense_tax_total'] = $expense['amount'] + expensetax::get_sum($expense_id); $detail['expense_tax_grouped'] = expensetax::grouped($expense_id); $detail['status_wording'] = $expense['status']==1?$LANG['paid']:$LANG['not_paid']; $taxes = $SI_TAX->fetchAllActive(); #$tax_selected = getTaxRate($product['default_tax_id']); $defaults = $SI_SYSTEM_DEFAULTS->fetchAll(); $smarty -> assign('expense',$expense); $smarty -> assign('detail',$detail); $smarty -> assign('taxes',$taxes); $smarty -> assign('defaults',$defaults); $smarty -> assign('tax_selected',$tax_selected);
checkLogin(); #get the invoice id $expense_id = $_GET['id']; $expenseobj = new expense(); $customerobj = new customer(); $billerobj = new biller(); $invoiceobj = new invoice(); $productobj = new product(); $expenseaccountobj = new expenseaccount(); $expensetaxobj = new expensetax(); $expense = $expenseobj->get($expense_id); $detail = $expenseobj->detail(); $detail['customer'] = $customerobj->get($expense['customer_id']); $detail['biller'] = $billerobj->select($expense['biller_id']); $detail['invoice'] = $invoiceobj->select($expense['invoice_id']); $detail['product'] = $productobj->get($expense['product_id']); $detail['expense_account'] = $expenseaccountobj->select($expense['expense_account_id']); $detail['expense_tax'] = $expensetaxobj->get_all($expense_id); $detail['expense_tax_total'] = $expense['amount'] + $expensetaxobj->get_sum($expense_id); $detail['expense_tax_grouped'] = $expensetaxobj->grouped($expense_id); $detail['status_wording'] = $expense['status'] == 1 ? $LANG['paid'] : $LANG['not_paid']; $taxes = getActiveTaxes(); #$tax_selected = getTaxRate($product['default_tax_id']); $defaults = getSystemDefaults(); $smarty->assign('expense', $expense); $smarty->assign('detail', $detail); $smarty->assign('taxes', $taxes); $smarty->assign('defaults', $defaults); //$smarty -> assign('tax_selected',$tax_selected); //$smarty -> assign('customFieldLabel',$customFieldLabel); $smarty->assign('pageActive', 'expense');
function deleteAccessories($productId) { $sentData = $this->input->post('sendData'); $sentData = trim($sentData, '-'); $sentData = explode("-", $sentData); array_push($sentData, "0"); $acc = new product(); $acc->where_in('id', $sentData); $acc->get(); $product = new Product($productId); $product->delete($acc->all, 'accessory'); }
function showCart() { $step = 1; if ($this->uri->segment(2, "") != "") { $stepStr = $this->uri->segment(2, ""); $stepStr = explode("-", $stepStr); $step = $stepStr[1]; if ($step != '2' && $step != '3') { show_404(); } if (!$this->_checkLogin()) { redirect('dang-nhap/' . 'gio-hang/buoc-' . $step); } } //get product from cookie $cartDetail = $this->getCartCookie(); $product = new product(); $productList = array(0); $store = new store(); $store->get_iterated(); $dis['store'] = $store; foreach ($cartDetail as $key => $value) { array_push($productList, $key); } $product->where_in('id', $productList); $product->get(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $cart = new Cartitem(); $cart->customer_id = $this->customer->id; $cart->shipType = $this->input->post('receiveType'); $cart->paymentType = $this->input->post('payment'); $cart->deliverStore_id = $this->input->post('branchReceive'); $cart->paymentStore_id = $this->input->post('branchPayment'); $cart->shipName = $this->input->post('info_name'); $cart->shipEmail = $this->input->post('info_email'); $cart->shipPhone = $this->input->post('info_phone'); $cart->shipDescription = $this->input->post('info_description'); $cart->shipAddress = $this->input->post('info_address'); $cart->status = enum::CART_WAIT_FOR_PROCESS; $cart->save(); $sum = 0; foreach ($product as $row) { $cartDetailItem = new Cartdetail(); $cartDetailItem->cartitem_id = $cart->id; $cartDetailItem->product_id = $row->id; $cartDetailItem->quantity = $cartDetail[$row->id]; $cartDetailItem->price = $row->getRealPriceNum(); $cartDetailItem->productName = $row->name; $cartDetailItem->inBox = $row->inBox; $cartDetailItem->status = enum::CARTDETAIL_AVAILABLE; $cartDetailItem->save(); $cartDetailItem->clear(); $itemTotal = $cartDetail[$row->id] * $row->getRealPriceNum(); $sum += $itemTotal; } $cart->total = $sum; $cart->save(); $this->sendMailCustomer($cart->id); $this->sendMailCustomerService($cart->id); //save cart detail setcookie("userCart", json_encode(array()), mktime() . time() + 60 * 60 * 24 * 7, "/"); $dis['view'] = 'cart/cart4'; } else { $dis['step'] = $step; $dis['product'] = $product; $dis['cartDetail'] = $cartDetail; $dis['view'] = 'cart/cart1'; } $dis['base_url'] = base_url(); $this->viewfront($dis); }