diff --git a/apps/maarch_entreprise/Models/ContactsModel.php b/apps/maarch_entreprise/Models/ContactsModel.php index ed92f026f78d75f3a100870a5c2cc776e42b16d6..93b766324580072d5ee4450be3432b3c28afbb59 100644 --- a/apps/maarch_entreprise/Models/ContactsModel.php +++ b/apps/maarch_entreprise/Models/ContactsModel.php @@ -1,24 +1,21 @@ <?php -/* -* Copyright 2015 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. + +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. * -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ +/** +* @brief Contacts Model +* @author dev@maarch.org +* @ingroup apps +*/ + +//namespace Apps\Models\Contacts; + require_once 'apps/maarch_entreprise/Models/ContactsModelAbstract.php'; class ContactsModel extends ContactsModelAbstract diff --git a/apps/maarch_entreprise/Models/ContactsModelAbstract.php b/apps/maarch_entreprise/Models/ContactsModelAbstract.php index a8c3a690173dd78dd8c2db2d9dc9e4f53142dbec..336e0c19be8f84d74d9435daabab2e996cc1dd10 100644 --- a/apps/maarch_entreprise/Models/ContactsModelAbstract.php +++ b/apps/maarch_entreprise/Models/ContactsModelAbstract.php @@ -1,35 +1,29 @@ <?php -/* -* Copyright 2015 Maarch +/** +* Copyright Maarch since 2008 under licence GPLv3. +* See LICENCE.txt file at the root folder for more details. +* This file is part of Maarch software. * -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. */ +/** +* @brief Contacts Model +* @author dev@maarch.org +* @ingroup apps +*/ + +//namespace Apps\Models\Contacts; + require_once 'apps/maarch_entreprise/services/Table.php'; class ContactsModelAbstract extends Apps_Table_Service { - public static function getById(array $aArgs = []) { static::checkRequired($aArgs, ['id']); static::checkNumeric($aArgs, ['id']); - $aReturn = static::select([ 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], 'table' => ['contacts_v2'], @@ -72,4 +66,19 @@ class ContactsModelAbstract extends Apps_Table_Service return $labelledContact; } + public static function getByEmail(array $aArgs = []) + { + static::checkRequired($aArgs, ['email']); + static::checkString($aArgs, ['email']); + + $aReturn = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['view_contacts'], + 'where' => ['email = ? and enabled = ?'], + 'data' => [$aArgs['email'], 'Y'], + 'order' => ['creation_date'], + ]); + + return $aReturn; + } } \ No newline at end of file diff --git a/core/Controllers/ResController.php b/core/Controllers/ResController.php index 55c35742345915bb83cbcf2bef021436dd100b83..60c147692e171c83886f12ea86cfc000e04d8af1 100644 --- a/core/Controllers/ResController.php +++ b/core/Controllers/ResController.php @@ -19,6 +19,7 @@ use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Respect\Validation\Validator; use Core\Models\UserModel; +use Core\Models\ResModel; use Entities\Models\EntitiesModel; use Core\Controllers\DocserverController; @@ -33,7 +34,6 @@ class ResController //print_r($aArgs['data']); $aArgs['data'] = json_decode($aArgs['data']); $aArgs['data'] = $this->object2array($aArgs['data']); - //print_r($aArgs['data']);exit; } $return = $this->storeResource($aArgs); @@ -411,42 +411,122 @@ class ResController return ['errors' => 'table ' . _EMPTY]; } + if (empty($aArgs['resTable'])) { + return ['errors' => 'resTable ' . _EMPTY]; + } + + $resDetails = ResModel::getById([ + 'resId' => $aArgs['resId'], + 'table' => $aArgs['resTable'], + 'select' => ['res_id'] + ]); + + if (empty($resDetails[0]['res_id'])) { + return ['errors' => 'res_id ' . _OF . ' ' . $aArgs['resTable'] . ' ' . _NOT_EXISTS]; + } - $func = new functions(); + $resDetails = ResModel::getById([ + 'resId' => $aArgs['resId'], + 'table' => $aArgs['table'], + 'select' => ['res_id'] + ]); + + if ($resDetails[0]['res_id'] > 0) { + return ['errors' => 'res_id ' . _OF . ' ' . $aArgs['table'] . ' ' . _EXISTS]; + } + + $prepareData = $this->prepareStorageExt($aArgs); + $resExtInsert = ResModel::create([ + 'table' => 'mlb_coll_ext', + 'data' => $prepareData + ]); + + return true; + } + + /** + * Convert an object to an array + * @param $object object to convert + */ + private function object2array($object) + { + $return = null; + if (is_array($object)) { + foreach ($object as $key => $value) { + $return[$key] = $this->object2array($value); + } + } else { + if (is_object($object)) { + $var = get_object_vars($object); + if ($var) { + foreach ($var as $key => $value) { + $return[$key] = ($key && !$value) ? null : $this->object2array($value); + } + } else { + return $object; + } + } else { + return $object; + } + } + return $return; + } + + /** + * Prepares storage on database for resExt. + * @param $data array + * @return array $data + */ + public function prepareStorageExt($aArgs) + { + if (empty($aArgs['resId'])) { + return ['errors' => 'resId ' . _EMPTY]; + } + if (empty($aArgs['data'])) { + return ['errors' => 'data ' . _EMPTY]; + } + if (empty($aArgs['table'])) { + return ['errors' => 'table ' . _EMPTY]; + } $queryExtFields = '('; $queryExtValues = '('; $queryExtValuesFinal = '('; $parameters = array(); - $db = new Database(); $findProcessLimitDate = false; $findProcessNotes = false; $delayProcessNotes = 0; - for ($i = 0; $i < count($data); $i++) { + $resId = $aArgs['resId']; + $table = $aArgs['table']; + $data = $aArgs['data']; + $countD = count($data); + for ($i = 0; $i < $countD; $i++) { if ($data[$i]['column'] == 'process_limit_date') { $findProcessLimitDate = true; } if ($data[$i]['column'] == 'process_notes') { $findProcessNotes = true; - $donnees = explode(',', $data[$i]['value']); - $delayProcessNotes = $donnees['0']; - $calendarType = $donnees['1']; + $don = explode(',', $data[$i]['value']); + $delayProcessNotes = $don['0']; + $calendarType = $don['1']; } } if ($table == 'mlb_coll_ext') { if ($delayProcessNotes > 0) { - $processLimitDate = $this->retrieveProcessLimitDate( - $resId, - $delayProcessNotes, - $calendarType - ); + $processLimitDate = ResModel::retrieveProcessLimitDate([ + 'resId' => $resId, + 'delayProcessNotes' => $delayProcessNotes, + 'calendarType' => $calendarType, + ]); } else { - $processLimitDate = $this->retrieveProcessLimitDate($resId); + $processLimitDate = ResModel::retrieveProcessLimitDate([ + 'resId' => $resId + ]); } } - + if (!$findProcessLimitDate && $processLimitDate <> '') { array_push( $data, @@ -457,10 +537,14 @@ class ResController ) ); } - - for ($i = 0; $i < count($data); $i++) { - if (strtoupper($data[$i]['type']) == 'INTEGER' || - strtoupper($data[$i]['type']) == 'FLOAT') { + require_once 'apps/maarch_entreprise/class/class_chrono.php'; + $chronoX = new \chrono(); + require_once 'apps/maarch_entreprise/Models/ContactsModel.php'; + $contacts = new \ContactsModel(); + for ($i=0; $i<count($data); $i++) { + if (strtoupper($data[$i]['type']) == 'INTEGER' || + strtoupper($data[$i]['type']) == 'FLOAT' + ) { if ($data[$i]['value'] == '') { $data[$i]['value'] = '0'; } @@ -469,126 +553,66 @@ class ResController if (strtoupper($data[$i]['column']) == strtoupper('category_id')) { $categoryId = $data[$i]['value']; } - if (strtoupper($data[$i]['column']) == strtoupper('alt_identifier') && - $data[$i]['value'] == "") { - require_once 'apps' . DIRECTORY_SEPARATOR . $_SESSION['config']['app_id'] - . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_chrono.php'; - $chronoX = new chrono(); - for ($iColl=0; $iColl<=count($_SESSION['collections']); $iColl++) { - if ($_SESSION['collections'][$iColl]['extensions'][0] == $table) { - $resViewTable = $_SESSION['collections'][$iColl]['view']; - break; - } + if (strtoupper($data[$i]['column']) == strtoupper('alt_identifier') && + $data[$i]['value'] == "" + ) { + if ($table == 'mlb_coll_ext') { + $resDetails = ResModel::getById([ + 'resId' => $resId, + 'table' => 'res_letterbox', + 'select' => ['destination, type_id'] + ]); + $myVars = array( + 'entity_id' => $resDetails[0]['destination'], + 'type_id' => $resDetails[0]['type_id'], + 'category_id' => $categoryId, + 'folder_id' => "", + ); + $myChrono = $chronoX->generate_chrono($categoryId, $myVars, 'false'); + $data[$i]['value'] = $myChrono; } - $stmt = $db->query("SELECT destination, type_id FROM " . $resViewTable - . " WHERE res_id = ?", array($resId)); - $resView = $stmt->fetchObject(); - $myVars = array( - 'entity_id' => $resView->destination, - 'type_id' => $resView->type_id, - 'category_id' => $categoryId, - 'folder_id' => "", - ); - $myChrono = $chronoX->generate_chrono($categoryId, $myVars, 'false'); - $data[$i]['value'] = $myChrono; } if (strtoupper($data[$i]['column']) == strtoupper('exp_contact_id') && - $data[$i]['value'] <> "" && !is_numeric($data[$i]['value'])) { + $data[$i]['value'] <> "" && + !is_numeric($data[$i]['value']) + ) { $theString = str_replace(">", "", $data[$i]['value']); $mail = explode("<", $theString); - $stmt = $db->query("SELECT contact_id FROM view_contacts WHERE email = ? " - . " and enabled = 'Y' order by creation_date asc", array($mail[count($mail) -1])); - $contact = $stmt->fetchObject(); - - if ($contact->contact_id <> "") { - $data[$i]['value'] = $contact->contact_id; + $contactDetails =$contacts->getByEmail([ + 'email' => $mail[count($mail) -1], + 'select' => ['contact_id'] + ]); + if ($contactDetails[0]['contact_id'] <> "") { + $data[$i]['value'] = $contactDetails[0]['contact_id']; } else { $data[$i]['value'] = 0; } + $data[$i]['type'] = 'integer'; } if (strtoupper($data[$i]['column']) == strtoupper('address_id') && - $data[$i]['value'] <> "" && !is_numeric($data[$i]['value'])) { + $data[$i]['value'] <> "" && + !is_numeric($data[$i]['value']) + ) { $theString = str_replace(">", "", $data[$i]['value']); $mail = explode("<", $theString); - $stmt = $db->query("SELECT ca_id FROM view_contacts WHERE email = ? " - . " and enabled = 'Y' order by creation_date asc", array($mail[count($mail) -1])); - $contact = $stmt->fetchObject(); - if ($contact->ca_id <> "") { - $data[$i]['value'] = $contact->ca_id; + $contactDetails =$contacts->getByEmail([ + 'email' => $mail[count($mail) -1], + 'select' => ['ca_id'] + ]); + if ($contactDetails[0]['ca_id'] <> "") { + $data[$i]['value'] = $contactDetails[0]['ca_id']; } else { $data[$i]['value'] = 0; } + $data[$i]['type'] = 'integer'; } //COLUMN $data[$i]['column'] = strtolower($data[$i]['column']); - $queryExtFields .= $data[$i]['column'] . ','; //VALUE - if ($data[$i]['type'] == 'string' || $data[$i]['type'] == 'date') { - $queryExtValues .= "'" . $data[$i]['value'] . "',"; - } else { - $queryExtValues .= $data[$i]['value'] . ","; - } - $parameters[] = $data[$i]['value']; - $queryExtValuesFinal .= "?,"; - } - $queryExtFields = preg_replace('/,$/', ',res_id)', $queryExtFields); - $queryExtValues = preg_replace( - '/,$/', - ',' . $resId . ')', - $queryExtValues - ); - $queryExtValuesFinal = preg_replace( - '/,$/', - ',' . $resId . ')', - $queryExtValuesFinal - ); - - $queryExt = " insert into " . $table . " " . $queryExtFields - . ' values ' . $queryExtValuesFinal ; - - $returnCode = 0; - if ($db->query($queryExt, $parameters)) { - $returnResArray = array( - 'returnCode' => (int) 0, - 'resId' => $resId, - 'error' => '', - ); - } else { - $returnResArray = array( - 'returnCode' => (int) -2, - 'resId' => '', - 'error' => 'Pb with SQL insertion', - ); + $parameters[$data[$i]['column']] = $data[$i]['value']; } - return $returnResArray; - - } + $parameters['res_id'] = $resId; - /** - * Convert an object to an array - * @param $object object to convert - */ - private function object2array($object) - { - $return = null; - if (is_array($object)) { - foreach ($object as $key => $value) { - $return[$key] = $this->object2array($value); - } - } else { - if (is_object($object)) { - $var = get_object_vars($object); - if ($var) { - foreach ($var as $key => $value) { - $return[$key] = ($key && !$value) ? null : $this->object2array($value); - } - } else { - return $object; - } - } else { - return $object; - } - } - return $return; + return $parameters; } } diff --git a/core/Models/ResModelAbstract.php b/core/Models/ResModelAbstract.php index 44817889c72f58a087b79a058c10383c5f4b2725..27c910f210370426dd42c7a455590e2bd263f7d4 100644 --- a/core/Models/ResModelAbstract.php +++ b/core/Models/ResModelAbstract.php @@ -19,4 +19,136 @@ require_once 'apps/maarch_entreprise/services/Table.php'; class ResModelAbstract extends \Apps_Table_Service { + /** + * Retrieve info of resId + * @param $resId integer + * @param $table string + * @param $select string + * @return array $res + */ + public static function getById(array $aArgs = []) + { + static::checkRequired($aArgs, ['resId']); + static::checkNumeric($aArgs, ['resId']); + + if (!empty($aArgs['table'])) { + $table = $aArgs['table']; + } else { + $table = 'res_letterbox'; + } + + $aReturn = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => [$table], + 'where' => ['res_id = ?'], + 'data' => [$aArgs['resId']] + ]); + + return $aReturn; + } + + /** + * Retrieve process_limit_date for resource in extension table if mlb + * @param $resId integer + * @param $defaultDelay integer + * @param $calendarType sring => calendar or workingDay + * @return integer $processLimitDate + */ + public function retrieveProcessLimitDate($aArgs) + { + static::checkRequired($aArgs, ['resId']); + static::checkNumeric($aArgs, ['resId']); + if (!empty($aArgs['table'])) { + $table = $aArgs['table']; + } else { + $table = 'res_view_letterbox'; + } + $processLimitDate = ''; + $aArgs['select'] = ['creation_date, admission_date, type_id']; + $aReturn = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => [$table], + 'where' => ['res_id = ?'], + 'data' => [$aArgs['resId']] + ]); + require_once('core/class/class_functions.php'); + $func = new \functions(); + + if ($aReturn[0]['type_id'] <> '') { + $typeId = $aReturn[0]['type_id']; + $admissionDate = $aReturn[0]['admission_date']; + $creationDate = $aReturn[0]['creation_date']; + $aArgs['select'] = ['process_delay']; + $aReturnT = static::select([ + 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], + 'table' => ['mlb_doctype_ext'], + 'where' => ['type_id = ?'], + 'data' => [$aReturn[0]['type_id']] + ]); + $delay = $aReturnT[0]['process_delay']; + } + + if ($admissionDate == '') { + $dateToCompute = $creationDate; + } else { + $dateToCompute = $admissionDate; + } + if ($aArgs['defaultDelay'] > 0) { + $delay = $aArgs['defaultDelay']; + } elseif ($delay == 0) { + $delay = 5; + } + require_once('core/class/class_alert_engine.php'); + $alert_engine = new \alert_engine(); + if (isset($dateToCompute) && !empty($dateToCompute)) { + $convertedDate = $alert_engine->dateFR2Time( + str_replace( + "-", + "/", + $func->format_date_db( + $dateToCompute, + 'true', + '', + 'true' + ) + ), + true + ); + $date = $alert_engine->WhenOpenDay( + $convertedDate, + $delay, + false, + $aArgs['calendarType'] + ); + } else { + $date = $alert_engine->date_max_treatment($delay, false); + } + + $processLimitDate = $func->dateformat($date, '-'); + + return $processLimitDate; + } + + /** + * insert into a resTable + * @param $resId integer + * @param $table string + * @return boolean $status + */ + public static function create(array $aArgs = []) + { + if (empty($aArgs['table'])) { + $aArgs['table'] = 'res_letterbox'; + } else { + if ($aArgs['table'] <> 'res_letterbox' && + $aArgs['table'] <> 'mlb_coll_ext' + ) { + $aArgs['table'] = 'res_letterbox'; + } + } + + $aReturn = static::insertInto($aArgs['data'], $aArgs['table']); + + return $aReturn; + } } diff --git a/core/Test/ResControllerTest.php b/core/Test/ResControllerTest.php index afccc1a219d31714ca80b9d46178191ece094568..ccec883019fbce43654a2aff8964eba5905e99ac 100644 --- a/core/Test/ResControllerTest.php +++ b/core/Test/ResControllerTest.php @@ -121,10 +121,16 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase $this->assertGreaterThanOrEqual(0, $response[0]); } - public function testStoreExtResource() + public function testCreate() { $action = new \Core\Controllers\ResController(); + $environment = \Slim\Http\Environment::mock( + [ + 'REQUEST_METHOD' => 'POST', + ] + ); + $path = $_SESSION['config']['tmppath'] . '/test/'; if (!is_dir($path)) { @@ -139,6 +145,7 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase $fileContent = file_get_contents($path . $fileSource, FILE_BINARY); $encodedFile = base64_encode($fileContent); + //echo $encodedFile . PHP_EOL;exit; $data = []; @@ -146,7 +153,7 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase $data, array( 'column' => 'subject', - 'value' => 'UNIT TEST', + 'value' => 'UNIT TEST from slim', 'type' => 'string', ) ); @@ -177,6 +184,11 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase 'type' => 'string', ) ); + //print_r(json_encode($data)); + //sample in json : [{"column":"subject","value":"UNIT T + //EST from slim","type":"string"},{"column":"type_id","value":110,"type":"integer"}, + //{"column":"custom_t1","value":"TES + //T","type":"string"},{"column":"custom_t10","value":"lgi@maarch.org","type":"string"}] $aArgs = [ 'encodedFile' => $encodedFile, @@ -187,45 +199,122 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase 'status' => 'new', ]; - //TODO - //$response = $action->storeExtResource($aArgs); - - $this->assertGreaterThanOrEqual(0, $response); + $request = \Slim\Http\Request::createFromEnvironment($environment); + $response = new \Slim\Http\Response(); + $response = $action->create($request, $response, $aArgs); + //print_r($response);exit; + $this->assertGreaterThan(1, json_decode($response->getBody())[0]); } - public function testCreate() + public function testPrepareStorageExt() { $action = new \Core\Controllers\ResController(); - $environment = \Slim\Http\Environment::mock( - [ - 'REQUEST_METHOD' => 'POST', - ] + $data = []; + + array_push( + $data, + array( + 'column' => 'process_limit_date', + 'value' => '29/03/2017', + 'type' => 'date', + ) ); - $path = $_SESSION['config']['tmppath'] . '/test/'; + array_push( + $data, + array( + 'column' => 'process_notes', + 'value' => '50,workingDay', + 'type' => 'string', + ) + ); - if (!is_dir($path)) { - mkdir($path); - } + array_push( + $data, + array( + 'column' => 'category_id', + 'value' => 'incoming', + 'type' => 'string', + ) + ); - $fileSource = 'test_source.txt'; + array_push( + $data, + array( + 'column' => 'alt_identifier', + 'value' => '', + 'type' => 'string', + ) + ); - $fp = fopen($path . $fileSource, 'a'); - fwrite($fp, 'a unit test'); - fclose($fp); + array_push( + $data, + array( + 'column' => 'exp_contact_id', + 'value' => 'jeanlouis.ercolani@maarch.org', + 'type' => 'string', + ) + ); - $fileContent = file_get_contents($path . $fileSource, FILE_BINARY); - $encodedFile = base64_encode($fileContent); - //echo $encodedFile . PHP_EOL;exit; + array_push( + $data, + array( + 'column' => 'address_id', + 'value' => 'jeanlouis.ercolani@maarch.org', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'nature_id', + 'value' => 'simple_mail', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'admission_date', + 'value' => date('d/m/Y'), + 'type' => 'date', + ) + ); + + $aArgs = [ + 'resId' => 100, + 'data' => $data, + 'table' => 'mlb_coll_ext', + ]; + + $response = $action->prepareStorageExt($aArgs); + + $this->assertArrayHasKey('res_id', $response); + } + + public function testStoreExtResource() + { + $action = new \Core\Controllers\ResController(); $data = []; array_push( $data, array( - 'column' => 'subject', - 'value' => 'UNIT TEST from slim', + 'column' => 'process_limit_date', + 'value' => '29/03/2017', + 'type' => 'date', + ) + ); + + array_push( + $data, + array( + 'column' => 'process_notes', + 'value' => '50,workingDay', 'type' => 'string', ) ); @@ -233,17 +322,17 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase array_push( $data, array( - 'column' => 'type_id', - 'value' => 110, - 'type' => 'integer', + 'column' => 'category_id', + 'value' => 'incoming', + 'type' => 'string', ) ); array_push( $data, array( - 'column' => 'custom_t1', - 'value' => 'TEST', + 'column' => 'alt_identifier', + 'value' => '', 'type' => 'string', ) ); @@ -251,30 +340,49 @@ class ResControllerTest extends \PHPUnit_Framework_TestCase array_push( $data, array( - 'column' => 'custom_t10', - 'value' => 'lgi@maarch.org', + 'column' => 'exp_contact_id', + 'value' => 'jeanlouis.ercolani@maarch.org', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'address_id', + 'value' => 'jeanlouis.ercolani@maarch.org', + 'type' => 'string', + ) + ); + + array_push( + $data, + array( + 'column' => 'nature_id', + 'value' => 'simple_mail', 'type' => 'string', ) ); - //print_r(json_encode($data)); - //sample in json : [{"column":"subject","value":"UNIT T - //EST from slim","type":"string"},{"column":"type_id","value":110,"type":"integer"}, - //{"column":"custom_t1","value":"TES - //T","type":"string"},{"column":"custom_t10","value":"lgi@maarch.org","type":"string"}] + + array_push( + $data, + array( + 'column' => 'admission_date', + 'value' => date('d/m/Y'), + 'type' => 'date', + ) + ); $aArgs = [ - 'encodedFile' => $encodedFile, - 'data' => $data, - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', - 'fileFormat' => 'txt', - 'status' => 'new', + 'resId' => 100, + 'data' => $data, + 'table' => 'mlb_coll_ext', + 'resTable' => 'res_letterbox', ]; - $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = new \Slim\Http\Response(); - $response = $action->create($request, $response, $aArgs); - //print_r($response);exit; - $this->assertGreaterThan(1, json_decode($response->getBody())[0]); + //TODO + $response = $action->storeExtResource($aArgs); + + $this->assertTrue($response); } }