} else { ob_start(); $a = ob_get_clean(); $responce = array('status' => 'failed', 'error' => 'Data missing' . $a, 'data' => array()); } } else { if ($form_id == 6) { if (isset($_POST['customer_name']) and !empty($_POST['customer_name']) and isset($_POST['contact_number']) and !empty($_POST['contact_number'])) { $customer = new customer(); $customer->customer_name = $_POST['customer_name']; $customer->contact_number = $_POST['contact_number']; $user = new user(); $user->id = $_SESSION['user_id']; $user->getUser(); $customer->company_id = $user->company_id; if ($customer->addCustomer()) { $message = "Customer added successfully"; $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message)); } else { Log::e($tag, "Customer adding failed Customer : " . $customer->to_string() . 'Error : ' . mysql_error()); $mysql_error = mysql_error(); if (empty($mysql_error)) { $error_message = 'Some server error occured'; } else { $error_message = $mysql_error; } $responce = array('status' => 'failed', 'error' => $error_message, 'data' => array()); } } else { ob_start(); $a = ob_get_clean();
//Check user is already login or not checkAuthentication(); $id = $_SESSION['adminid']; $customer = new customer(); if (isset($_GET['action']) && $_GET['action'] == 'new') { $smarty->assign('content', $smarty->fetch('addcustomer.tpl')); } elseif (isset($_GET['action']) && $_GET['action'] == 'edit') { $id = $_GET['id']; $smarty->assign('customer', $customer->getCustomer($id)); $smarty->assign('billing', $customer->getCustomerBilling($id)); $smarty->assign('shipping', $customer->getCustomerShipping($id)); $smarty->assign('tax', $customer->getCustomerTax($id)); $smarty->assign('content', $smarty->fetch('editcustomer.tpl')); } elseif (isset($_POST['action']) && $_POST['action'] == 'add') { $data = $_POST['data']['Customer']; if ($customer->addCustomer($data)) { header('Location: ' . FRONTEND . 'customer.php'); exit; } } elseif (isset($_POST['action']) && $_POST['action'] == 'update') { $data = $_POST['data']['Customer']; if ($customer->updateCustomer($data)) { header('Location: ' . FRONTEND . 'customer.php'); exit; } } elseif (isset($_GET['action']) && $_GET['action'] == 'search') { $keyword = $_POST['keywords']; $smarty->assign('customer', $customer->getSearchCustomers($keyword)); $smarty->assign('content', $smarty->fetch('customerlist.tpl')); } else { $page = 1;