diff --git a/apps/maarch_entreprise/Models/ContactsModelAbstract.php b/apps/maarch_entreprise/Models/ContactsModelAbstract.php index 336e0c19be8f84d74d9435daabab2e996cc1dd10..10f887bdd29f1722a820aabfbd610c5a92f57f76 100644 --- a/apps/maarch_entreprise/Models/ContactsModelAbstract.php +++ b/apps/maarch_entreprise/Models/ContactsModelAbstract.php @@ -76,7 +76,7 @@ class ContactsModelAbstract extends Apps_Table_Service 'table' => ['view_contacts'], 'where' => ['email = ? and enabled = ?'], 'data' => [$aArgs['email'], 'Y'], - 'order' => ['creation_date'], + 'order_by' => ['creation_date'], ]); return $aReturn; diff --git a/core/Controllers/ResController.php b/core/Controllers/ResController.php index 3705692c8b59a7cae558f780c07b6bbbffd01a9b..f807dd3b8f9707f789abcd7da59d262fa8d4cbee 100644 --- a/core/Controllers/ResController.php +++ b/core/Controllers/ResController.php @@ -154,22 +154,18 @@ class ResController 'data' => $data, ]; - $resId = $this->loadIntoDb($aArgs); - var_dump($resId); - exit; + $this->loadIntoDb($aArgs); + + $resDetails = ResModel::getByPath([ + 'docserverId' => $storeResult['docserver_id'], + 'path' => $storeResult['destination_dir'], + 'filename' => $storeResult['file_destination_name'], + 'table' => $aArgs['table'], + 'select' => ['res_id'] + ]); + + $resId = $resDetails[0]['res_id']; - require_once 'core/class/class_resource.php'; - $resource = new \resource(); - $resId = $resource->load_into_db( - $table, - $storeResult['destination_dir'], - $storeResult['file_destination_name'], - $storeResult['path_template'], - $storeResult['docserver_id'], - $data, - $_SESSION['config']['databasetype'], - true - ); if (!is_numeric($resId)) { return ['errors' => 'Pb with SQL insertion : ' .$resId]; @@ -193,7 +189,7 @@ class ResController * @param $filename string Resource file name * @param $docserverPath string Docserver path * @param $docserverId string Docserver identifier - * @param $data array Data array + * @param boolean */ public function loadIntoDb($aArgs) { @@ -302,35 +298,13 @@ class ResController //VALUE $prepareData[$data[$i]['column']] = $data[$i]['value']; } - var_dump($prepareData); $resInsert = ResModel::create([ 'table' => 'res_letterbox', 'data' => $prepareData ]); - var_dump($resInsert); - - exit; - if (!$this->insert($table, $data, $_SESSION['config']['databasetype'])) { - if (!$calledByWs) { - $this->error = _INDEXING_INSERT_ERROR."<br/>".$this->show(); - } - return false; - } else { - $db2 = new Database(); - $stmt = $db2->query( - "select res_id from " . $table - . " where docserver_id = ? and path = ? and filename= ? order by res_id desc ", - array( - $docserverId, - $path, - $filename - ) - ); - $res = $stmt->fetchObject(); - return $res->res_id; - } + return true; } } diff --git a/core/Models/ResModelAbstract.php b/core/Models/ResModelAbstract.php index 27c910f210370426dd42c7a455590e2bd263f7d4..ad58c36da302dd02bcce45bad3df65426f27ed20 100644 --- a/core/Models/ResModelAbstract.php +++ b/core/Models/ResModelAbstract.php @@ -47,6 +47,38 @@ class ResModelAbstract extends \Apps_Table_Service return $aReturn; } + /** + * Retrieve info of resId by path + * @param $docserverId string + * @param $path string + * @param $filename string + * @param $table string + * @param $select string + * @return array $res + */ + public static function getByPath(array $aArgs = []) + { + static::checkRequired($aArgs, ['docserverId']); + static::checkRequired($aArgs, ['path']); + static::checkRequired($aArgs, ['filename']); + + if (!empty($aArgs['table'])) { + $table = $aArgs['table']; + } else { + $table = 'res_letterbox'; + } + + $aReturn = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => [$table], + 'where' => ['docserver_id = ? and path = ? and filename = ?'], + 'data' => [$aArgs['docserverId'], $aArgs['path'], $aArgs['filename']], + 'order_by' => ['res_id desc'], + ]); + + return $aReturn; + } + /** * Retrieve process_limit_date for resource in extension table if mlb * @param $resId integer