/var/www/doncode.com.ua/www/models
NameSizeModeActions
class.admin_model.php377020644editdlrm
class.api_model.php328640644editdlrm
class.archive_model.php29750644editdlrm
class.arm_model.php93930644editdlrm
class.dcccatalog_model.php98710644editdlrm
class.dcclist_model.php108290644editdlrm
class.dccsupport_model.php4710644editdlrm
class.dccupdate_model.php4700644editdlrm
class.dmp_platforms_model.php79590644editdlrm
class.docs_model.php11280644editdlrm
class.doncode_users_model.php67120644editdlrm
class.driver_model.php3690644editdlrm
class.exchange_model.php82660644editdlrm
class.files_model.php1940644editdlrm
class.index_model.php11290644editdlrm
class.login_model.php250140644editdlrm
class.mobile_users_model.php100090644editdlrm
class.news_model.php77210644editdlrm
class.orders_model.php97820644editdlrm
class.settings_model.php117990644editdlrm
class.support_model.php287830644editdlrm
class.users_model.php91540644editdlrm
class.user_model.php448730644editdlrm
Edit: /var/www/doncode.com.ua/www/models/class.orders_model.php (9782B)
form->post('number','номер телефона')->val('digit')->val('emptyStr'); $this->form->submit(); $data = $this->form->fetch(); }catch(Exception $e){ ajax::fail($e->getMessage()); return false; } try{ $sth = $this->database->prepare ("SELECT `id`,`name`,`pincode`,`gid`,`reg_date`,`last_date`,`last_sms`,`city_id`,`auto_type`,`partner` FROM `orders` WHERE `deleted`=0 LIMIT 1 "); if (strlen($data['number'])>10){ $number = substr($data['number'],strlen($data['number'])-10); }else{ $number = $data['number']; } $sth->execute(array( ':phone'=> $number) ); }catch(PDOException $e){ ajax::fail($e->getMessage()); return false; } if($sth->rowCount()==0){ echo json_encode(array('none'=>time())); return false; }else{ echo json_encode($sth->fetch()); } } public function fetchCountRecords(){ $sth = $this->database->prepare('SELECT count(id) as `count` FROM `orders` WHERE `deleted`=\'0\'; '); $sth->execute(); return $sth->fetch (); } public function fetchSingleRecordsFromCode(){ $msg_fail = "Не найден покупатель. "; try{ $this->form->post('code')->val('emptyStr'); $this->form->submit(); $data = $this->form->fetch(); }catch(Exception $e){ ajax::fail( $msg_fail.$e->getMessage() ); return false; } try{ $sth = $this->database->prepare("SELECT * FROM `orders` WHERE `deleted`='0' AND `deleted` ='0' LIMIT 1;"); $sth->execute(array(':code'=>$data['code'])); }catch(PDOException $e){ ajax::fail( $msg_fail ); return false; } if ($sth->rowCount() > 0) echo json_encode($sth->fetch()); else ajax::fail( $msg_fail ); } public function getTypeOrders (){ try{ $sth = $this->database->prepare("SELECT * FROM `orders`"); $sth->execute(); return $sth->fetchAll(); }catch(PDOException $e){ return array(); } } public function clientsGetList ($page=0){ if ($page!=0){ $page_number=abs(($page-1)*LIMIT); }else{ $page_number=0; } try{ $sth=$this->database->prepare("SELECT d.gid,c.city_name_ru FROM `dcc` d INNER JOIN `city_` c ON c.id_city=d.city_id LIMIT 1000"); $sth->execute(); $r = $sth->fetchAll(); foreach($r as $k => $v){ $gids[$v['gid']] = $v['city_name_ru']; } $sth=$this->database->prepare("SELECT o.* FROM `orders` o ORDER BY o.`create_time` DESC LIMIT $page_number , ".LIMIT." "); $sth->execute(); $data = $sth->fetchAll(); foreach($data as $k => $v){ $data[$k]['a'] = $gids[$v['a']]; //$data[$k]['b'] = $gids[$v['b']]; } }catch(PDOException $e){ ajax::fail($e->getMessage()); return false; } $max_sum_call = 0; if($sth->rowCount()>0){ //$arr= $sth->fetchAll(); echo json_encode($data); }else{ if($page_number==0){ ajax::fail( 'нет DCC, а это очень грутсно :(' ); return false; } $page_number-=1; $this->clientsGetList($page_number); } } public function fetchSingleRecordsFromId ($id,$ajax=true){ $sth=$this->database->prepare("SELECT d.*,c.city_name_ru as cName, co.country_name_ru as coName FROM `dcc` d INNER JOIN `city_` c ON (d.city_id=c.id_city) INNER JOIN `country_` co ON (co.id_country=c.id_country) WHERE d.deleted='0' AND `id`=:id"); $sth->execute(array(':id'=>$id)); if ($ajax){ echo json_encode($sth->fetch()); }else{ return $sth->fetch(); } } public function get_pay_type ($ajax=true){ $sth=$this->database->prepare("SELECT * FROM `pay_type` WHERE deleted='0'"); $sth->execute(); if ($ajax){ echo json_encode($sth->fetch()); }else{ return $sth->fetchAll(); } } public function deleteRecords($id){ $sth=$this->database->prepare("UPDATE `orders` SET `deleted`='1' WHERE `id`=$id ;"); $sth->execute(); if ($sth->rowCount()>0){ echo json_encode(array('msg'=>'success')); $this->database->log('Удален клиент id='.$id); }else{ echo json_encode(array('msg'=> 'fail')); $this->database->log('Не удалось удалить клиента id='.$id); } } public function saveEditRecords ( ){ try{ $this->form->post('id')->val('digit')->val('zeroField') ->post('name') ->post('pincode') ->post('gid') ->post('reg_date') ->post('last_date') ->post('last_sms') ->post('city_id') ->post('auto_type') ->post('partner'); $this->form->submit(); $data = $this->form->fetch(); if(isset($data['obmen'])){ if($data['obmen']=='on'){ $data['obmen']=1; }else{ $data['obmen']=0; } }else{ $data['obmen']=0; } if(isset($data['internet'])){ if($data['internet']=='on'){ $data['internet']=1; }else{ $data['internet']=0; } }else{ $data['internet']=0; } }catch(Exception $e){ ajax::fail($e->getMessage()); $this->database->log('Не удалось обновить данные DCC '.$e->getMessage() ); return false; } try{ $id=$data['id']; unset($data['id']); $this->database->update('dcc',$data,'id='.$id); }catch(PDOException $e){ ajax::fail($e->getMessage()); $this->database->log('Не удалось обновить данные DCC '.$e->getMessage() ); return false; } ajax::success("Данные клиента ".$data['orders']." обновлены."); $this->database->log("Данные клиента ".$data['orders']." обновлены." ); } public function createOrders(){ try{ $this->form->post('FIO','ФИО')->val('emptyStr') ->post('email') ->post('phone','телефон')->val('emptyStr') ->post('adress') ->post('town') ->post('discount') ->post('code_clients') ->post('type'); $this->form->submit(); $data = $this->form->fetch(); }catch(Exception $e){ if(ajax::check_ajax_request()){ ajax::fail($e->getMessage()); }else{ session::set('msgFail',$e->getMessage()); $this->database->log('Не удалось создать Ordersа '.$e->getMessage() ); header("Location:".$_SERVER["HTTP_REFERER"]); } exit; } try{ $this->database->insert('orders',$data); }catch(PDOException $e){ session::set('msgFail',$e->getMessage()); $this->database->log('Не удалось создать Ordersа '.$data['FIO']); header("Location:".$_SERVER["HTTP_REFERER"]); exit; } if(ajax::check_ajax_request()){ ajax::success("Создан Orders ".$data['FIO']); }else{ session::set('msgSuccess',"Создан Orders ".$data['FIO']); $this->database->log('Создан Orders '.$data['FIO']); header("Location:".URL."orders"); } exit; } public function search ($ch,$type){ try{ $char = $this->database->quote('%'.$ch.'%'); $sth = $this->database->prepare("SELECT `serverip`,`taxi_name` FROM `orders` WHERE `$type` LIKE $char AND `deleted`='0' LIMIT ".LIMIT); $sth->execute( ); ajax::out($sth->fetchAll()); } catch (Exception $e){ ajax::fail($e->getMessage()); return false; } } public function fetechOrders ($id){ try{ $sth = $this->database->prepare("SELECT c.*,t.name as tName FROM `orders` c INNER JOIN `type_orders` t ON (c.type=t.id) WHERE c.deleted='0' AND c.id=:id LIMIT 1 "); $sth->execute(array(':id'=>$id)); ajax::out($sth->fetchAll()); return; }catch(PDOException $e){ ajax::fail($e->getMessage()); return ; } } }