コード例 #1
0
ファイル: BusinessEntity.php プロジェクト: sasadjolic/SailOn
 public function EditEntity($bo)
 {
     $db = new Database();
     $newID = UUID::newID();
     $ID = str_replace("sys", "", $bo["EntityName"]) . "id";
     if ($bo[$ID] != null) {
         $values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo);
         $sql = 'UPDATE ' . $bo["EntityName"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"';
     } else {
         //
         $fields = str_replace($ID . ",", "", $bo["EntityFields"]);
         $values = SqlHelper::GetValues(explode(",", $fields), $bo);
         $sql = 'INSERT INTO ' . $bo["EntityName"] . '(' . $ID . ',' . $fields . ')' . ' VALUES("' . $newID . '",' . $values . ')';
         //table
         if ($bo["EntityName"] == 'sysentity') {
             $table = ';CREATE TABLE IF NOT EXISTS ' . $bo["Name"] . '(' . $bo["Name"] . 'ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' . $bo["Name"] . 'ID))ENGINE = InnoDB';
             $sql .= $table;
         }
         if ($bo["EntityName"] == 'sysproperty') {
             $result = $db->RunSQL('SELECT Name FROM SysEntity WHERE EntityID = ' . $bo["EntityID"]);
             $table = ';ALTER TABLE ' . $result[0]['Name'] . ' ADD COLUMN ' . $bo["Name"] . ' VARCHAR(45) NULL ';
             $sql .= $table;
         }
     }
     $result = $db->ExecuteSQL($sql);
     return $this->GetEntityView($bo["RefreshEntityViewID"], array("id" => $newID));
 }
コード例 #2
0
ファイル: BusinessEntity.php プロジェクト: sasadjolic/SailOn
 public function EditEntity($bo)
 {
     $db = new Database();
     $newID = UUID::newID();
     $propertyID = UUID::newID();
     $ID = str_replace("sys", "", $bo["entityname"]) . "id";
     $ID_Field = str_replace("sys", "", $bo["name"]) . "id";
     //$sql = "START TRANSACTION;";
     if ($bo[$ID] != null) {
         $values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo);
         $sql .= 'UPDATE ' . $bo["entityname"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"';
         //echo $sql;
     } else {
         //
         $fields = str_replace("," . $ID . ",", ",", "," . $bo["EntityFields"] . ",");
         $fields = substr($fields, 1, $fields . length - 1);
         $values = SqlHelper::GetValues(explode(",", $fields), $bo);
         $sql .= 'INSERT INTO ' . $bo["entityname"] . '(' . $ID . ',' . $fields . ') VALUES("' . $newID . '",' . $values . ')';
         //echo $sql;
         //table
         if ($bo["entityname"] == 'sysentity') {
             $sql .= ';INSERT INTO sysproperty(propertyid, entityid, name) VALUES("' . $propertyID . '","' . $newID . '", "' . $ID_Field . '")';
             $table = ';CREATE TABLE IF NOT EXISTS ' . $bo["name"] . '(' . $ID_Field . ' VARCHAR(100) NOT NULL, ' . ' createddate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ' . 'PRIMARY KEY (' . $ID_Field . '))ENGINE = InnoDB';
             $sql .= $table;
             //echo $sql;
         }
         if ($bo["entityname"] == 'sysproperty' && !$bo["isonlyview"]) {
             $columnType = ' VARCHAR(255) NULL';
             if ($bo["xtype"] == "numberfield") {
                 $columnType = ' INT NULL';
             } else {
                 if ($bo["xtype"] == "datefield") {
                     $columnType = ' DATETIME NULL';
                 } else {
                     if ($bo["xtype"] == "textareafield") {
                         $columnType = ' TEXT NULL';
                     } else {
                         if ($bo["xtype"] == "checkboxfield") {
                             $columnType = ' BOOL NULL';
                         } else {
                             if ($bo["xtype"] == "htmleditor") {
                                 $columnType = ' TEXT NULL';
                             }
                         }
                     }
                 }
             }
             $result = $db->RunSQL('SELECT name FROM sysentity WHERE entityid = "' . $bo["entityid"] . '"');
             $table = ';ALTER TABLE ' . $result[0]['name'] . ' ADD COLUMN ' . $bo["name"] . ' ' . $columnType;
             $sql .= $table;
         }
     }
     //$sql .= ';COMMIT;';
     //echo $sql;
     $entity = array("entityViewID" => $bo["RefreshEntityViewID"]);
     $result = $db->ExecuteSQL($sql);
     return $this->GetEntityView($entity);
 }
コード例 #3
0
ファイル: Business.php プロジェクト: sasadjolic/SailOn
 public function SaveCustomFields($customFields)
 {
     $fields = "Name,TableName,Description,Type,Config";
     $sql = "";
     for ($i = 0; $i < count($customFields); $i++) {
         $field = $customFields[$i];
         if ($field["sysrowstate"] == "0") {
             $values = SqlHelper::GetValues(explode(",", $fields), $field);
             $sql .= 'ALTER TABLE ' . $field["TableName"] . ' ADD CF_' . $field["Name"] . ' VARCHAR( 255 );';
             $sql .= 'INSERT INTO CustomField(' . $fields . ') VALUES(' . $values . ');';
         } elseif ($field["sysrowstate"] == "1") {
             $sql .= 'UPDATE CustomField SET Description = "' . $field["Description"] . '",Config = "' . $field["Config"] . '" WHERE CFId = ' . $field["CFId"] . ';';
         } elseif ($field["sysrowstate"] == "2") {
             $sql .= 'UPDATE CustomField SET Archive = 1 WHERE CFId = ' . $field["CFId"] . ';';
         }
         //$sql = str_replace("#".$i, $param, $sql);
     }
     $db = new Database();
     $result = $db->ExecuteSQL($sql);
     return JSONHelper::GetJSON(array(), 'records');
 }
コード例 #4
0
ファイル: Business.php プロジェクト: sasadjolic/SailOn
 public function SaveBoat($bo)
 {
     $bo['boatid'] = UUID::newID();
     $fields = $bo["EntityFields"];
     $values = SqlHelper::GetValues(explode(",", $fields), $bo);
     $sql = 'INSERT INTO boat(' . $fields . ')' . ' VALUES(' . $values . ')';
     $db = new Database();
     $db->ExecuteSQL($sql);
     return JSONHelper::GetJSON(array('boatid' => $bo['boatid']), 'result');
 }
コード例 #5
0
ファイル: Helpers.php プロジェクト: sasadjolic/SailOn
 public static function GetSqlFromRows($fields, $rows, $table, $fk, $fkVal, $idField)
 {
     $sql = '';
     $values = '';
     for ($i = 0; $i < count($rows); ++$i) {
         $row = $rows[$i];
         if ($fk) {
             $row[$fk] = $fkVal;
         }
         if ($idField) {
             $row[$idField] = UUID::newID();
         }
         $values = SqlHelper::GetValues(explode(",", $fields), $row);
         $sql .= 'INSERT INTO ' . $table . '(' . $fields . ') VALUES(' . $values . ');';
     }
     return $sql;
 }
コード例 #6
0
ファイル: Business.php プロジェクト: sasadjolic/SailOn
 public function SaveDivision($bo)
 {
     $id = UUID::newID();
     $fields = 'name,groupname,handicaptype,handicapvalue,description';
     $values = SqlHelper::GetValues(explode(",", $fields), $bo);
     if ($bo['divisionid']) {
         $sql = 'update division set name = "' . $bo['name'] . '", groupname = "' . $bo['groupname'] . '", handicaptype = "' . $bo['handicaptype'] . '", handicapvalue = "' . $bo['handicapvalue'] . '", description = "' . $bo['description'] . '" where divisionid = "' . $bo['divisionid'] . '"';
     } else {
         $sql = 'insert into division(divisionid, name, groupname, description, handicaptype, handicapvalue) VALUES("' . $id . '","' . $bo['name'] . '","' . $bo['groupname'] . '","' . $bo['description'] . '","' . $bo['handicaptype'] . '","' . $bo['handicapvalue'] . '")';
     }
     $db = new Database();
     $db->ExecuteSQL($sql);
     return JSONHelper::GetJSON($id, 'result');
 }