Exemplo n.º 1
0
 public function ls($filter = 1, $sort = "", $limit = "")
 {
     $sql = "SELECT `id`,`name`,`description` FROM `" . $this->table() . "`";
     $filter = "(`deleted`=0 AND `id`>0) AND (" . $filter . ")";
     list($list, $fields) = parent::_ls($sql, $filter, $sort, $limit);
     $list = $this->ls_numeric($list, array("uid"));
     return array($list, $fields);
 }
Exemplo n.º 2
0
 public function ls($filter = 1, $sort = "", $limit = "")
 {
     $sql = "SELECT `a`.`id`,`a`.`name`, `a`.`sku`, `d`.`sign` AS `currency`, `a`.`indicative_price` AS `price`, `c`.`name` AS `vat`, `b`.`name` AS `type`\n\t\t\t\t\tFROM `" . $this->table() . "`AS `a` \n\t\t\t\t\tLEFT JOIN `" . $this->table() . "_type` AS `b` ON (`a`.`inventory_type_id`=`b`.`id` AND `b`.`deleted`=0) \n\t\t\t\t\tLEFT JOIN `##_SPACE_vat` AS `c` ON (`a`.`indicative_vat_id`=`c`.`id`)\n\t\t\t\t\tLEFT JOIN `##_SPACE_currency` AS `d` ON (`a`.`indicative_currency_id`=`d`.`id`)";
     $filter = "(`a`.`deleted`=0 AND `a`.`id`>0 AND `b`.`deleted`=0 AND `c`.`deleted`=0 AND `d`.`deleted`=0) AND (" . $filter . ")";
     list($list, $fields) = parent::_ls($sql, $filter, $sort, $limit);
     $list = $this->ls_money($list, array("price"));
     return array($list, $fields);
 }
Exemplo n.º 3
0
 public function updateFromObject($obj)
 {
     global $DBO;
     if ($obj->id == -1) {
         $sql = file_get_contents(FS_VAR . 'new_customer.sql');
         $sql = str_replace("_SPACE_", "_" . $DBO->escape($obj->space) . "_", $sql);
         $DBO->query($sql);
     }
     $obj = parent::_updateFromObject($obj);
     return $this->get("id");
 }
Exemplo n.º 4
0
 public function rm($id)
 {
     global $DBO;
     $r = parent::_rm($id);
     if (is_array($id)) {
         $sql = "UPDATE `" . $this->table() . "_address` SET `deleted`='1' WHERE `entity_id` IN ('" . implode("','", $id) . "');";
         $DBO->query($sql);
         return true;
     } elseif (is_string($id) || is_numeric($id)) {
         $sql = "UPDATE `" . $this->table() . "_address` SET `deleted`='1' WHERE `entity_id`='" . $id . "';";
         $DBO->query($sql);
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 public function updateFromObject($obj)
 {
     global $DBO;
     if (isset($obj->user_id)) {
         $user_id = $obj->user_id;
         unset($obj->user_id);
     } else {
         $user_id = array();
     }
     if (isset($obj->ace_id)) {
         $ace_id = $obj->ace_id;
         unset($obj->ace_id);
     } else {
         $ace_id = array();
     }
     $obj = parent::_updateFromObject($obj);
     foreach ($user_id as $k => $v) {
         if (is_null($v)) {
             unset($user_id[$k]);
         }
     }
     $user_id = $this->cleanPropertyArray($user_id);
     $sql = "SELECT `auth_user_id` FROM `##_auth_user_role` WHERE `auth_role_id`='" . $this->get("id") . "' AND `deleted`='0';";
     $DBO->query($sql);
     $aur = array();
     foreach ($DBO->result("objectlist") as $v) {
         $aur[] = $v->auth_user_id;
     }
     $d = array_diff($aur, $user_id);
     if (count($d) > 0) {
         $sql = "UPDATE `##_auth_user_role` SET `deleted`='1' WHERE `auth_role_id`='" . $this->get("id") . "' AND `auth_user_id` IN ('" . implode("','", $d) . "');";
         echo $sql;
         $DBO->query($sql);
     }
     $d = array_diff($user_id, $aur);
     if (count($d) > 0) {
         $change = array();
         foreach ($d as $did) {
             $change[] = "('" . $this->get("id") . "','{$did}')";
         }
         $sql = "INSERT INTO `##_auth_user_role` (`auth_role_id`,`auth_user_id`) VALUES " . implode(",", $change) . ";";
         echo $sql;
         $DBO->query($sql);
     }
     $ace_id = $this->cleanPropertyArray($ace_id);
     $sql = "SELECT `auth_ace_id` FROM `##_auth_acl` WHERE `auth_role_id`='" . $this->get("id") . "' AND `deleted`='0';";
     $DBO->query($sql);
     $ac = array();
     foreach ($DBO->result("objectlist") as $v) {
         $ac[] = $v->auth_ace_id;
     }
     $d = array_diff($ac, $ace_id);
     if (count($d) > 0) {
         $sql = "UPDATE `##_auth_acl` SET `deleted`='1' WHERE `auth_role_id`='" . $this->get("id") . "' AND `auth_ace_id` IN ('" . implode("','", $d) . "');";
         $DBO->query($sql);
     }
     $d = array_diff($ace_id, $ac);
     if (count($d) > 0) {
         $change = array();
         foreach ($d as $did) {
             $change[] = "('" . $this->get("id") . "','{$did}')";
         }
         $sql = "INSERT INTO `##_auth_acl` (`auth_role_id`,`auth_ace_id`) VALUES " . implode(",", $change) . ";";
         $DBO->query($sql);
     }
     return $this->get("id");
 }
Exemplo n.º 6
0
 public function ls($filter = 1, $sort = "", $limit = "")
 {
     $sql = "SELECT `a`.`id`,`a`.`name`, `a`.`type`, `a`.`amount`\n\t\t\t\t\tFROM `" . $this->table() . "` AS `a`";
     $filter = "(`a`.`deleted`=0 AND `a`.`id`>=0) AND (" . $filter . ")";
     return parent::_ls($sql, $filter, $sort, $limit);
 }
Exemplo n.º 7
0
 public function updateFromObject($obj)
 {
     global $DBO;
     if (isset($obj->role_id)) {
         $role_id = $obj->role_id;
         unset($obj->role_id);
     } else {
         $role_id = array();
     }
     $password = "";
     if (isset($obj->password)) {
         $pass = $obj->password;
         unset($obj->password);
     }
     $obj = parent::_updateFromObject($obj);
     if ($password !== "") {
         $this->setPassword($password);
     }
     foreach ($role_id as $k => $v) {
         if (is_null($v)) {
             unset($role_id[$k]);
         }
     }
     $sql = "SELECT `auth_role_id` FROM `##_auth_user_role` WHERE `auth_user_id`='" . $this->get("id") . "' AND `deleted`='0';";
     $DBO->query($sql);
     $aui = array();
     foreach ($DBO->result("objectlist") as $r) {
         $aui[] = $r->auth_role_id;
     }
     $d = array_diff($aui, $role_id);
     if (count($d) > 0) {
         $sql = "UPDATE `##_auth_user_role` SET `deleted`='1' WHERE `auth_user_id`='" . $this->get("id") . "' AND `auth_role_id` IN ('" . implode("','", $d) . "');";
         $DBO->query($sql);
     }
     $d = array_diff($role_id, $aui);
     if (count($d) > 0) {
         $change = array();
         foreach ($d as $did) {
             $change[] = "('" . $this->get("id") . "','{$did}')";
         }
         $sql = "INSERT INTO `##_auth_user_role` (`auth_user_id`,`auth_role_id`) VALUES " . implode(",", $change) . ";";
         $DBO->query($sql);
     }
     return $this->get("id");
 }
Exemplo n.º 8
0
 public function ls($filter = 1, $sort = "", $limit = "")
 {
     $sql = "SELECT `a`.`id`,`a`.`name`, `a`.`export_to`, `a`.`recurrence`, `b`.`timestamp` AS `last_run`, IF(`b`.`exit_status`=0,'" . RES_SUCCESS . "','" . RES_FAILED . "') AS `exit_status`\n\t\t\t\t\tFROM `" . $this->table() . "` AS `a` \n\t\t\t\t\tLEFT JOIN (SELECT * FROM `" . $this->table() . "_log` ORDER BY `timestamp` DESC LIMIT 0,1) AS `b` ON (`b`.`crontab_id`=`a`.`id`)";
     $filter = "(`a`.`deleted`=0 AND `a`.`id`>=0 AND `b`.`deleted`=0) AND (" . $filter . ")";
     return parent::_ls($sql, $filter, $sort, $limit);
 }