public function add_customer($post) { $customer = new Model_Customer(); $customer->values($post); $this->create($customer); return $customer; }
public function action_index() { $config = Fuel\Core\Config::get('pagination'); $pagination = Fuel\Core\Pagination::forge('admin.currencies', $config); $pagination->total_items = Model_Customer::count(); $data['pagination'] = $pagination; $data['currencies'] = Model_Currency::find('all', array('order_by' => array(array('country', 'asc')), 'limit' => $pagination->per_page, 'offset' => $pagination->offset)); $this->template->title = "Currencies"; $this->template->content = View::forge('admin/currencies/index', $data); }
public function action_delete($id = null) { if ($customer = Model_Customer::find($id)) { $customer->delete(); Session::set_flash('success', e('Deleted customer #' . $id)); } else { Session::set_flash('error', e('Could not delete customer #' . $id)); } Response::redirect('admin/customers'); }
/** * Deletes a customer. * * @param Model_Customer $customer The customer to delete. * * @return bool */ public static function delete(Model_Customer $customer) { $customer->status = 'deleted'; try { $customer->save(); } catch (FuelException $e) { Log::error($e); return false; } Service_Event::trigger('customer.delete', $customer->seller, $customer->to_array()); return true; }
public function action_delete($id = null) { if ($customer = Model_Customer::find($id)) { if (!$customer->projects) { $customer->delete(); Session::set_flash('success', e('Deleted customer #' . $id)); } else { Fuel\Core\Session::set_flash('error', e('This customer has ' . count($customer->projects) . ' projects and cannot be deleted.')); } } else { Session::set_flash('error', e('Could not delete customer #' . $id)); } Response::redirect('admin/customers'); }
public function loadDebtors(array $debtors) { if (!$this->validateDebtors($debtors)) { return false; } $this->clearDebtors(); foreach ($debtors as $arr) { $customer = Model_Customer::find_by_custid($arr[0]); if (!is_null($customer)) { $this->Debtors[$customer->custid] = array('customer' => $customer, 'amount' => $arr[1]); } } $this->save(); return $this; }
public function action_index() { $pagination = \Fuel\Core\Pagination::forge('userprojects', array('pagination_url' => \Fuel\Core\Config::get('pagination.pagination_url', '') . 'user/projects/index/', 'total_items' => Model_Project::count(array('related' => array('customer', 'project_members'), 'where' => array(array('project_members.user_id', $this->current_user->id)))), 'per_page' => \Fuel\Core\Config::get('pagination.per_page', 10), 'num_links' => \Fuel\Core\Config::get('pagination.num_links', 10), 'uri_segment' => \Fuel\Core\Config::get('pagination.uri_segment', 4), 'show_first' => \Fuel\Core\Config::get('pagination.show_first', false), 'show_last' => \Fuel\Core\Config::get('pagination.show_last', false))); $view = Fuel\Core\View::forge('user/projects/index'); $view->set_global('user_is_admin', false); $view->set_global('projects', Model_Project::find('all', array('related' => array('customer', 'project_members'), 'order_by' => array('customer.name' => 'asc', 'name' => 'asc'), 'where' => array(array('project_members.user_id', $this->current_user->id)), 'limit' => $pagination->per_page, 'offset' => $pagination->offset))); $view->set_global('customers', \Fuel\Core\Arr::assoc_to_keyval(Model_Customer::find('all', array('order_by' => array('name' => 'asc'))), 'id', 'name')); $view->set_global('project_statuses', Model_Projectstatus::find('all', array('order_by' => array(array('description', 'asc'))))); $view->set_global('selected_status_id', \Fuel\Core\Config::get('projects.default_status_id', 0)); $view->set_global('user_is_admin', $this->check_user_is_admin()); $view->set_global('project_status_id', 0); $view->set_global('selected_status_id', 0); $view->set_global('pagination', $pagination, false); $view->set_global('admin', false); $this->template->title = 'My Projects'; $this->template->content = $view; }
public function action_filter() { $user_id = \Fuel\Core\Input::param('user_id', 0); $client_id = Fuel\Core\Input::param('client_id', 0); $project_id = \Fuel\Core\Input::param('project_id', 0); $month = Fuel\Core\Input::param('month', '00'); $year = Fuel\Core\Input::param('year', date('Y')); $status = 0; $data['open_tasks'] = THelper::get_tasks($user_id, $client_id, $project_id, $month, $year, $status, array(\Fuel\Core\Input::param('sort', 'priority') => \Fuel\Core\Input::param('order', 0))); $view = \Fuel\Core\View::forge('admin/tasks/index'); $view->set_global('clients', Model_Customer::find('all', array('order_by' => array('name' => 'asc')))); $view->set_global('users', Model_User::find('all', array('order_by' => array('username' => 'asc')))); $view->set_global('years', range(2015, date('Y'))); $view->set_global('months', THelper::get_months_array()); $view->set_global('open_tasks', $data['open_tasks']); $view->set_global('admin', true); $this->template->title = 'Open Tasks'; $this->template->content = $view; }
<?php include '../includes/config.inc.php'; include 'baseapi.php'; $customer_id = (int) $_WGT['m_customer_id']; $token = substr(md5('wgt' . $customer_id), 0, 15); $wechatObj = new baseapi($token, $customer_id); $custModel = new Model_Customer(); $filter['where'] = " id='{$customer_id}' and is_valid='1' "; $sql = $custModel->select($filter, 'is_yz'); $result = $custModel->fetchRow($sql); if ($result['is_yz'] == '1') { echo $wechatObj->responseMsg(); } else { echo $wechatObj->valid(); }
<?php include_once "../includes/config.inc.php"; $customer_id = $_WGT['m_customer_id']; $id = (int) $_REQUEST['id']; $t = $_REQUEST['t']; if ($t == 'single') { $infocommonModel = new Model_InfoCommon(); $filter['where'] = " customer_id='{$customer_id}' and id='{$id}' "; $sql = $infocommonModel->select($filter, '*'); $info = $infocommonModel->fetchRow($sql); $info['info_intro'] = nl2br($info['info_intro']); } elseif ($t == 'multi') { $infocommondetailModel = new Model_InfoCommonDetail(); $filter['where'] = " id='{$id}' "; $sql = $infocommondetailModel->select($filter, '*'); $info = $infocommondetailModel->fetchRow($sql); $info['info_title'] = $info['title']; $info['info_intro'] = nl2br($info['msg_content']); $info['pic_showincontent'] = 1; $info['info_pic'] = $info['pic']; } $customerModel = new Model_Customer(); $filter['where'] = " id='{$customer_id}' "; $sql = $customerModel->select($filter, 'id,weixin_name'); $customerinfo = $customerModel->fetchRow($sql); $smarty->assign("customerinfo", $customerinfo); $smarty->assign("info", $info); $smarty->assign("today", date("Y-m-d")); $smarty->setLayout('')->setTpl('/mobile/templates/info.html')->display();
public function valid() { $echoStr = $_GET["echostr"]; $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $tmpArr = array($this->token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode($tmpArr); $tmpStr = sha1($tmpStr); if ($tmpStr == $signature) { $custModel = new Model_Customer(); $data = array(); $data['id'] = $this->customer_id; $data['is_yz'] = 1; $custModel->upsert($data); return $echoStr; } }