public function find_customer($id = null) { APP::import('Model','Customer'); $this->Customer = new Customer(); $cus = $this->Customer->find('first',array('conditions'=>array('Customer.id'=>$id))); return $cus['Customer']['customername'].'('.$cus['Customer']['tag_name'].')'; }
/** * add shop to folder * */ public function rankFolder($conditions, $user_id) { APP::import("Model", array("User")); $this->User = new User(); $user = $this->User->findById($user_id); $folder = $this->find('list', array('conditions' => $conditions, "group by" => "Folder.id", "order" => "FolderUser.modified DESC", 'fields' => array('FolderUser.id', 'FolderUser.id'))); $rank_folder = array(); if (!empty($folder)) { if (empty($user["User"]["rank_folder"])) { $rank_folder = $folder; } else { $list = explode(",", $user["User"]["rank_folder"]); $listRank = array(); foreach ($list as $val) { if (!empty($folder[$val])) { $listRank[] = $val; } } $rank_folder = array_merge($listRank, $folder); $rank_folder = array_unique($rank_folder); } $user["User"]["rank_folder"] = implode(",", $rank_folder); $this->User->save($user); } return $rank_folder; }
public function getlog_approve_sales($salesorder_id=NULL) { APP::import('Model','Logactivity'); $this->Logactivity = new Logactivity(); $log_list = $this->Logactivity->find('first',array('conditions'=>array('Logactivity.logid'=>$salesorder_id))); return $log_list['User']['username']; }
public function dashboard_customer_name($module = NULL ,$value = NULL ,$chk_fld = NULL ,$get_fld = NULL ) { APP::import('Model',$module); $this->$module = new $module(); $result = $this->$module->find('first',array('conditions'=>array($module.'.'.$chk_fld=>$value))); if(!empty($result[$module][$get_fld])) return $result[$module][$get_fld]; }
/** * count shop in folder * */ public function getCountFolder($shop_id) { APP::import("Model", array("FolderShop")); $this->FolderShop = new FolderShop(); $data = $this->FolderShop->find("count", array("conditions" => array("FolderShop.shop_id" => $shop_id))); return $data; }
/** * データベースの接続先情報を取得する * * @access private * @author sakuragawa */ private function _getDbConnectInfo() { $dbConfigInfo = array(); $dbConfig = new DATABASE_CONFIG(); // 読み込まれているModel分ループ foreach ($this->controller->modelNames as $key => $val) { APP::import('Model', $this->controller->modelNames[$key]); $model = new $this->controller->modelNames[$key](); $useDbConfig = $model->useDbConfig; if (!isset($dbConfig->{$useDbConfig})) { // 定義されてない unset($model); continue; } // 接続設定 $one = $dbConfig->{$useDbConfig}; // 必要な分のみ取り出し $buf['driver'] = $one['driver']; $buf['host'] = $one['host']; $buf['database'] = $one['database']; if (count($dbConfigInfo) != 0) { // 初回以外 if (!in_array($buf, $dbConfigInfo)) { $dbConfigInfo[$useDbConfig] = $buf; } } else { // 初回 $dbConfigInfo[$useDbConfig] = $buf; } unset($model); } return $dbConfigInfo; }
public function checktag_list($group_id=NULL) { APP::import('Model','Customer'); $this->Customer = new Customer(); $group_data = $this->Customer->find('all',array('conditions'=>array('Customer.customergroup_id'=>$group_id,'Customer.status'=>1))); return count($group_data); }
function NewAnnex() { APP::import('Model', 'Annex'); $this->Annex = new Annex(); $this->Annex->create(); $this->Annex->save(); return $this->Annex->getLastInsertID(); }
public function get_customer_name($customer_id=NULL) { APP::import('Model','Clientpo'); $this->Customer = new Customer(); $customer = $this->Customer->find('first',array('conditions'=>array('Customer.id'=>$customer_id),'fields'=>array('Customertagname'))); if(!empty($customer)): return $customer['Customer']['Customertagname']; endif; }
public function Add($userId, $text) { APP::import('Model', 'Log'); $this->Log = new Log(); $this->Log->create(); $this->Log->set('user_id', $userId); $this->Log->set('message', $text); $this->Log->save(); }
public function blacklistCheck($data) { $site_url = strtolower($data['site_url']); //get restricted list from db APP::import("Model", "RestrictedName"); $this->RestrictedName = new RestrictedName(); if (!$this->RestrictedName->checkName($site_url)) { return false; } return true; }
public function checkdepartment_value($user_id=NULL,$department_id=NULL) { APP::import('Model','UserDepartment'); $this->UserDepartment = new UserDepartment(); $userdepartment = $this->UserDepartment->find('all',array('conditions'=>array('UserDepartment.user_id'=>$user_id,'UserDepartment.department_id'=>$department_id))); if(count($userdepartment)>0): return TRUE; else: return FALSE; endif; }
public function GetModelValueCount() { APP::import('Model', 'Scholar'); $this->Scholar = new Scholar(); $this->Scholar->recursive = -1; $count = $this->Scholar->find('count', array('conditions' => array('Scholar.scholar_situation =' => '0'))); if ($count == 0) { return ""; } return "<span class='badge badge-danger'>" . $count . "</span>"; }
function share($hasp = null) { $result = array("data" => array(), "error" => 1); if (empty($hasp)) { $user_id = @$this->request->data['user_id']; $folder_id = @$this->request->data['folder_id']; $this->user_id = $this->User->getUserIdByAPIToken(@$this->request->data['api_token']); } else { $secret = explode(self::PREFIX, Security::cipher(base64_decode($hasp), Configure::read('Security.salt'))); if (count($secret) < 4) { return $this->redirect(self::APP_STORE); } $this->user_id = $secret[0]; $user_id = $secret[1]; $folder_id = $secret[2]; } if (empty($user_id) || empty($folder_id) || empty($this->user_id)) { if (empty($hasp)) { return $this->responseOk($result); } else { return $this->redirect(self::APP_STORE); } } else { $my_user = $this->User->findById($this->user_id); $user = $this->User->findById($user_id); $folder = $this->FolderUser->find("first", array("conditions" => array("FolderUser.id" => $folder_id, "FolderUser.user_id" => $this->user_id))); if (empty($user) || empty($folder) || empty($my_user)) { if (empty($hasp)) { return $this->responseOk($result); } else { return $this->redirect(self::APP_STORE); } } } if (empty($hasp)) { $str = $this->randomString(); $hasp = $this->safe_b64encode(Security::cipher($this->user_id . self::PREFIX . $user_id . self::PREFIX . $folder_id . self::PREFIX . $str, Configure::read('Security.salt'))); $link = Router::url('/', true) . "Kaopass/share/{$hasp}"; $result["error"] = 0; $result["data"] = $link; return $this->responseOk($result); } else { APP::import("Model", array("FolderShare")); $folderShare = new FolderShare(); $folderShareData = $folderShare->find("first", array("conditions" => array("FolderShare.folder_id" => $folder_id, "FolderShare.user_id" => $user_id))); if ($folderShareData) { return $this->redirect(self::APP_KAOPASS); } $dataSave = array('user_id' => $user_id, "folder_id" => $folder_id); $folderShare->create(); $folderShare->save($dataSave); return $this->redirect(self::APP_KAOPASS); } }
public function main() { //run daily sales report APP::import("Model", "ReportDailySales"); $this->ReportDailySales = new ReportDailySales(); $this->ReportDailySales->generateDailySalesReport(); //run daily order report APP::import("Model", "ReportDailyOrders"); $this->ReportDailyOrders = new ReportDailyOrders(); $this->ReportDailyOrders->generateDailyOrdersReport(); }
function checkExistEmail($fields = array()) { APP::import("Model", array("User")); $data = $this->data; if (!empty($data['TmpUser']['mail_address'])) { $conditions["User.mail_address"] = $data['TmpUser']['mail_address']; $this->User = new User(); $user = $this->User->find("first", array("conditions" => $conditions, "fields" => "id")); if (!empty($user)) { return false; } } return true; }
public function GetModelFieldById($model, $field, $id) { try { APP::import('Model', $model); $this->{$model} = new $model(); $this->{$model}->recursive = -1; $daModel = $this->{$model}->findById($id); if (!$daModel) { throw new NotFoundException(__('Invalid model')); } return $daModel[$model][$field]; } catch (Exception $e) { return '-'; } }
function DeleteDocumentById($id, $path = 'path') { try { APP::import('Model', 'Document'); $this->Document = new Document(); $this->Document->recursive = -1; $document = $this->Document->findById($id); if (!$document) { //unlink(WWW_ROOT . DS . $path . DS . $document['Document']['filename']; $this->Document->id = $id; $this->Document->delete(); } } catch (Exception $e) { } }
function getInfoPush($user_id = null, $shop_id = null) { $result = array(); if (!empty($user_id)) { APP::import("Model", array("User", "Shop")); $this->User = new User(); $this->Shop = new Shop(); $user = $this->User->findById($user_id); $shop = $this->Shop->findById($shop_id); if (!empty($user)) { $result = array("name_user" => $user["User"]["name"], "name_shop" => @$shop["Shop"]["name"]); } } return $result; }
function updateCountUser($user_id) { $this->begin(); APP::import("Model", array("UserPvCount")); $this->UserPvCount = new UserPvCount(); $data = $this->find("first", array("conditions" => array("UserPvCount.date" => date("Y-m-d"), "UserPvCount.user_id" => $user_id), "fields" => array("UserPvCount.id", "UserPvCount.pv_counter"))); $this->create(); if (!empty($data)) { $dataSave = array("id" => $data['UserPvCount']['id'], "pv_counter" => $data['UserPvCount']['pv_counter'] + 1, "date" => date("Y-m-d"), "user_id" => $user_id); } else { $dataSave = array("pv_counter" => 1, "date" => date("Y-m-d"), "user_id" => $user_id); } if ($this->save($dataSave, false)) { $this->commit(); } else { $this->rollback(); } }
function send() { APP::import('vendor', 'phpmailer/calss.phpmailer.php'); // vendor('phpmailer'.DS.'class.phpmailer'); $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Host = $this->smtpHostNames; $mail->Port = $this->smtpPort; $mail->Username = $this->smtpUserName; $mail->Password = $this->smtpPassword; if ($this->useSSL) { $mail->SMTPSecure = 'ssl'; } $mail->From = $this->from; $mail->FromName = $this->fromName; $mail->AddAddress($this->to, $this->toName); $mail->AddReplyTo($this->from, $this->fromName); $mail->CharSet = 'UTF-8'; $mail->WordWrap = 50; // set word wrap to 50 characters if (!empty($this->attachments)) { foreach ($this->attachments as $attachment) { if (empty($attachment['asfile'])) { $mail->AddAttachment($attachment['filename']); } else { $mail->AddAttachment($attachment['filename'], $attachment['asfile']); } } } $mail->IsHTML(true); // set email format to HTML $mail->Subject = $this->subject; $mail->Body = $this->bodyHTML(); $mail->AltBody = $this->bodyText(); $result = $mail->Send(); if ($result == false) { $result = $mail->ErrorInfo; } return $result; }
/** * */ public function saveSocialFriends($user_id, $friends) { if (!$user_id || !$friends) { return false; } $data = array(); $list_id = array(); foreach ($friends as $value) { if (!$this->checkExistFriend($user_id, $value)) { $data[] = array('UserFriend' => array('user_id_a' => $user_id, 'user_id_b' => $value)); $list_id[] = $value; } } if (count($data) > 0) { APP::import("Model", array("User")); $this->User = new User(); $this->User->push_notification($list_id, "友達が追加されました"); return $this->saveAll($data); } return true; }
public function find_priority_type($id = null) { APP::import('Model','Priority'); $this->Priority = new priority(); //echo $id; $pri_type = $this->Priority->findById($id); //pr($pri_type); //pr($pri_type);exit; //pr($pri_type['Priority']['priority']);exit; // if($pri_type['Priority']['priority']=='') // { // return '0'; // } // else // { //pr($pri_type); return $pri_type['Priority']['priority']; //} // pr(count($data_count[0]['Description']));exit; }
public function customerinstrument($id = null) { APP::import('Model','CustomerInstrument'); $this->CustomerInstrument = new CustomerInstrument(); APP::import('Model','Instrument'); $this->Instrument = new Instrument(); APP::import('Model','Range'); $this->Range = new Range(); APP::import('Model','Customer'); $this->Customer = new Customer(); $data_0 = $this->CustomerInstrument->find('first',array('conditions'=>array('CustomerInstrument.id'=>$id))); $data_1 = $this->Instrument->find('first',array('conditions'=>array('Instrument.id'=>$data_0['CustomerInstrument']['instrument_id']))); $data_2 = $this->Range->find('first',array('conditions'=>array('Range.id'=>$data_0['CustomerInstrument']['range_id']))); $data_3 = $this->Customer->find('first',array('conditions'=>array('Customer.id'=>$data_0['CustomerInstrument']['customer_id']))); $instrumentname = $data_1['Instrument']['name']; $range = $data_2['Range']['range_name']; $model = $data_0['CustomerInstrument']['model_no']; $cost = $data_0['CustomerInstrument']['cost']; $customer = $data_3['Customer']['customername']; return $customer.' - '.$instrumentname.' - '.$range.' - '.$model.' - $'.$cost; }
public function index() { APP::import('Model', 'Instrumentforgroup'); /******************************************************* * BS V1.0 * User Role Permission * Controller : instrumentforgroup * Permission : view *******************************************************/ $user_role = $this->userrole_permission(); if ($user_role['ins_instrumentforgroup']['view'] == 0) { return $this->redirect(array('controller' => 'Dashboards', 'action' => 'index')); } $this->set('userrole_cus', $user_role['ins_instrumentforgroup']); /* * ***************************************************** */ //,array('conditions'=>array('Instrumentforgroup.status'=>'1'), $instrument_type_data = $this->InstrumentType->find('all', array('conditions' => array('InstrumentType.is_deleted' => 0))); //,array('group' => array('Instrumentforgroup.group_id')) $this->set('instrumentforgroups', $instrument_type_data); //pr($instrument_data);exit; }
public function unit_symbol($id = null) { APP::import('Model', 'Tempunit'); $this->Tempunit = new Tempunit(); $unit_data = $this->Tempunit->find('first', array('conditions' => array('Tempunit.id' => $id))); return $unit_data['Tempunit']['unitname']; }
function beforeFilter() { parent::beforeFilter(); App::import('Core', 'File'); APP::import('Core', 'Folder'); }
/** * Obtenemos los destinatarios segun el tipo de registro * * @param mixed $tipo * @param array $areas, array([0]=>1,[1]=>34..) * @param int $id id de la audiencia */ function _getDestinatarios($tipo = 'notificar_registro', $areas = array(), $id = null) { APP::import('Model', 'CoUser'); $users = new CoUser(); $to = ''; //destinatarios con formato de email switch ($tipo) { case 'notificar_registro': $users->recursive = -1; //Notificamos cuando se de de alta $consulta = $users->find('all', array('conditions' => array('CoUser.notificar_registro' => 1))); $i = 0; foreach ($consulta as $cons) { $to[$i]['name'] = $cons['CoUser']['nombre']; $to[$i]['email'] = $cons['CoUser']['email']; $i++; } break; case 'turnar': $users->recursive = -1; //Notificamos a todos los usuarios del area turnada $consulta = $users->find('all', array('conditions' => array('CoUser.area_id' => $areas))); $i = 0; foreach ($consulta as $cons) { $to[$i]['name'] = $cons['CoUser']['nombre']; $to[$i]['email'] = $cons['CoUser']['email']; // $to[$i]=$cons['CoUser']['nombre'].' <'.$cons['CoUser']['email'].'>'; // $to.=$cons['CoUser']['email']; $i++; } break; case 'observacion': $users->recursive = -1; //Notificamos cuando se agrega una observacion $consulta = $users->find('all', array('conditions' => array('CoUser.notificar_registro' => 1))); $i = 0; foreach ($consulta as $cons) { $to[$i]['name'] = $cons['CoUser']['nombre']; $to[$i]['email'] = $cons['CoUser']['email']; // $to.=$cons['CoUser']['email']; $i++; } break; case 'areas_turnadas': $users->recursive = -1; //Obtenemos las areas turnadas de la tabla audiencias_areas App::import('Model', 'AudienciasArea'); $thisAreas = new AudienciasArea(); $areas = $thisAreas->find('list', array('fields' => 'AudienciasArea.area_id,AudienciasArea.area_id', 'conditions' => array('AudienciasArea.audiencia_id' => $id))); //Notificamos a todos los usuarios del area turnada $consulta = $users->find('all', array('conditions' => array('CoUser.area_id' => $areas, 'CoUser.co_group_id' => array(3)))); //pr($consulta); $i = 0; foreach ($consulta as $cons) { $to[$i]['name'] = $cons['CoUser']['nombre']; $to[$i]['email'] = $cons['CoUser']['email']; // $to[$i]=$cons['CoUser']['nombre'].' <'.$cons['CoUser']['email'].'>'; // $to.=$cons['CoUser']['email']; $i++; } //pr($to);exit; break; } return $to; }
make_cache(true, $fileModified, 259200); $encoding = Configure::read("App.encoding"); if ($type === "css") { header("Content-Type: text/css;charset={$encoding}"); } else { if ($type === "js") { header("Content-Type: text/javascript;charset={$encoding}"); } } foreach ($filter as $v) { if (strpos($file, $v) !== false) { echo file_get_contents($file); exit; } } APP::import('vendor', 'inc/packer'); $p = new Packer(); echo $p->pack($file, $type); function make_cache($switch = false, $modified = 0, $expires = null) { if ($switch) { if (is_null($expires)) { $expires = 300; } if (!is_int($modified)) { $modified = 0; } @($oldmodified = $_SERVER["HTTP_IF_MODIFIED_SINCE"]); if ($oldmodified != "") { if (($pos = strpos($oldmodified, ';')) !== false) { $oldmodified = substr($oldmodified, 0, $pos);
/** * exec method * * @param mixed $cmd * @param mixed $out null * @return true on success, false on failure * @access protected */ protected function _exec($cmd, &$out = null) { if (!class_exists('Mi')) { APP::import('Vendor', 'Mi.Mi'); } return Mi::exec($cmd, $out); }