Пример #1
0
 function getDatatype($params)
 {
     $datatype = $params["datatype"];
     $template = new Model_Template();
     $data = $template->getDataVals($datatype);
     echo $this->view->render("datatype", array("data" => $data));
 }
Пример #2
0
 public function getDataTree($params)
 {
     $id = $params["id"];
     $template = new Model_Template();
     $tree = $template->getDataVals($id);
     echo $this->view->render("objects_datatree", array("tree" => $tree));
 }
Пример #3
0
 public function getForm($id)
 {
     $data = array();
     $sql = "SELECT f.id AS id, f.name AS `name`, ff.id AS fid, ff.field AS `field`, ff.type AS `type`, ff.datatype\r\n        FROM objects_forms AS f\r\n        LEFT JOIN objects_forms_fields AS ff ON (f.id = ff.tid)\r\n        WHERE f.id = :id\r\n        ORDER BY ff.id";
     $res = $this->registry['db']->prepare($sql);
     $param = array(":id" => $id);
     $res->execute($param);
     $fields = $res->fetchAll(PDO::FETCH_ASSOC);
     $templates = new Model_Template();
     for ($i = 0; $i < count($fields); $i++) {
         $fields[$i]["sel"] = $templates->getDataVals($fields[$i]["datatype"]);
     }
     $sql = "SELECT fid, x, y, w, h\r\n\t\t\t\t\tFROM objects_forms_view\r\n\t\t\t\t\tWHERE tid = :tid";
     $res = $this->registry['db']->prepare($sql);
     $param = array(":tid" => $id);
     $res->execute($param);
     $data = $res->fetchAll(PDO::FETCH_ASSOC);
     // если поле есть в таблице  templates_view, присвоим массиву $fields значения
     for ($i = 0; $i < count($fields); $i++) {
         for ($j = 0; $j < count($data); $j++) {
             if ($fields[$i]["fid"] == $data[$j]["fid"]) {
                 $fields[$i]["view"] = $data[$j];
             }
         }
     }
     // sort array
     for ($i = 0; $i < count($fields); $i++) {
         for ($j = 0; $j < count($fields); $j++) {
             if (isset($fields[$i]["view"]["y"]) and isset($fields[$j]["view"]["y"])) {
                 if ($fields[$i]["view"]["y"] < $fields[$j]["view"]["y"]) {
                     $min = $fields[$i];
                     $fields[$i] = $fields[$j];
                     $fields[$j] = $min;
                 }
             }
         }
     }
     return $fields;
 }
Пример #4
0
 public function runAction($rid, $step_id, $results)
 {
     $goto = null;
     $routes = new Model_RealRoute();
     $action = $routes->getRouteAction($step_id);
     if (count($action) == 0) {
         $goto = $this->countStep($rid, $step_id);
     } else {
         foreach ($action as $part) {
             $templates = new Model_Template();
             $sql = "SELECT datatype FROM route_tasks_results WHERE id = :ifdata LIMIT 1";
             $res = $this->registry['db']->prepare($sql);
             $param = array(":ifdata" => $part["ifdata"]);
             $res->execute($param);
             $row = $res->fetchAll(PDO::FETCH_ASSOC);
             $vals = $templates->getDataVals($row[0]["datatype"]);
             foreach ($results as $key => $val) {
                 foreach ($vals as $temps) {
                     if ($temps["id"] == $val) {
                         $id = $temps["val"];
                     }
                 }
                 if ($key == $part["ifdata"]) {
                     if ($part["ifcon"] == "=") {
                         if ($id == $part["ifval"]) {
                             $goto = $part["goto"];
                         }
                     } else {
                         if ($part["ifcon"] == "<") {
                             if ($id < $part["ifval"]) {
                                 $goto = $part["goto"];
                             }
                         } else {
                             if ($part["ifcon"] == ">") {
                                 if ($id > $part["ifval"]) {
                                     $goto = $part["goto"];
                                 }
                             } else {
                                 if ($part["ifcon"] == "!=") {
                                     if ($id != $part["ifval"]) {
                                         $goto = $part["goto"];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if ($goto == null) {
             $goto = $this->countStep($rid, $step_id);
         }
     }
     return $goto;
 }
Пример #5
0
 public function getObject($id)
 {
     $rows = FALSE;
     $sql = "SELECT o.id AS id, o.timestamp AS `timestamp`, o.template AS tid, o.fid AS fdirid, t.id AS tid, t.name AS tname, ov.fid AS fid, tf.field AS `field`, tf.main AS `main`, tf.type AS `type`, tf.datatype AS datatype, ov.val AS val, o.uid AS auid, author.name AS aname, author.soname AS asoname, o.timestamp AS adate, ov.uid AS euid, editor.name AS ename, editor.soname AS esoname, ov.timestamp AS edate\r\n\t\t\t\tFROM objects AS o\r\n                LEFT JOIN objects_vals AS ov ON (ov.oid = o.id)\r\n                LEFT JOIN templates_fields AS tf ON (tf.id = ov.fid)\r\n                LEFT JOIN templates AS t ON (t.id = tf.tid)\r\n                LEFT JOIN users AS author ON (author.id = o.uid)\r\n                LEFT JOIN users AS editor ON (editor.id = ov.uid)\r\n                WHERE o.id = :id\r\n                ORDER BY fid";
     $res = $this->registry['db']->prepare($sql);
     $param = array(":id" => $id);
     $res->execute($param);
     $rows = $res->fetchAll(PDO::FETCH_ASSOC);
     $template = new Model_Template();
     $fields = $template->getTypeTemplate($rows[0]["tid"]);
     for ($i = 0; $i < count($fields); $i++) {
         $flag = false;
         for ($j = 0; $j < count($rows); $j++) {
             if (isset($rows[$j]["val"])) {
                 $rows[$j]["formatval"] = nl2br($rows[$j]["val"]);
                 $search = array("\n", "\r");
                 $rows[$j]["formatval"] = str_replace($search, "", $rows[$j]["formatval"]);
             }
             if (isset($rows[$j]["field"])) {
                 if ($fields[$i]["field"] == $rows[$j]["field"]) {
                     $flag = true;
                     $rows[$i]["sel"] = $template->getDataVals($rows[$i]["datatype"]);
                 }
             }
         }
         if (!$flag) {
             $rows[] = $fields[$i];
         }
     }
     $sql = "SELECT `email`\r\n\t\tFROM mail_contacts\r\n\t\tWHERE oid = :id";
     $res = $this->registry['db']->prepare($sql);
     $param = array(":id" => $id);
     $res->execute($param);
     $email = $res->fetchAll(PDO::FETCH_ASSOC);
     if (count($email) and $email[0]["email"] != "") {
         $rows[0]["email"] = $email[0]["email"];
     }
     if ($rows) {
         $fields = $template->getTemplate($rows[0]["tid"]);
     } else {
         return FALSE;
     }
     foreach ($fields as $part) {
         $flag = FALSE;
         foreach ($rows as $row) {
             if ($part["fid"] == $row["fid"]) {
                 $flag = TRUE;
             }
         }
         if (!$flag) {
             $rows[] = $part;
         }
     }
     for ($i = 0; $i < count($rows); $i++) {
         $sql = "SELECT fid, x, y, w, h\r\n        \t\tFROM templates_view\r\n        \t\tWHERE tid = :tid";
         $res = $this->registry['db']->prepare($sql);
         $param = array(":tid" => $rows[0]["tid"]);
         $res->execute($param);
         $data = $res->fetchAll(PDO::FETCH_ASSOC);
     }
     // если поле есть в таблице  templates_view, присвоим массиву $fields значения
     for ($i = 0; $i < count($rows); $i++) {
         for ($j = 0; $j < count($data); $j++) {
             if ($rows[$i]["fid"] == $data[$j]["fid"]) {
                 $rows[$i]["view"] = $data[$j];
             }
         }
     }
     // sort array
     for ($i = 0; $i < count($rows); $i++) {
         for ($j = 0; $j < count($rows); $j++) {
             if (isset($rows[$i]["view"]["y"]) and isset($rows[$j]["view"]["y"])) {
                 if ($rows[$i]["view"]["y"] < $rows[$j]["view"]["y"]) {
                     $min = $rows[$i];
                     $rows[$i] = $rows[$j];
                     $rows[$j] = $min;
                 }
             }
         }
     }
     return $rows;
 }