diff --git a/apps/maarch_entreprise/define_custom.php b/apps/maarch_entreprise/define_custom.php index e4d5636fbd2ceb2fb0aa3303ff38188ef98dab62..75923e4442cd60c0cdf19f37f7305420e56a781d 100644 --- a/apps/maarch_entreprise/define_custom.php +++ b/apps/maarch_entreprise/define_custom.php @@ -19,3 +19,7 @@ */ // Write your custom define + +if (!defined('PROD_MODE')) { + define('PROD_MODE', false); +} diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index db738f560cdb2cb428f9e1f0e1bcc2a3cf30d4d3..536dbbb153644815cf3628e503abb53324437e5a 100644 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -518,6 +518,7 @@ if (!defined("_ACTION_MODIFIED")) define("_ACTION_MODIFIED","Action modification if (!defined("_NEW_ACTION")) define("_NEW_ACTION", "New action"); if (!defined("_THE_ACTION")) define("_THE_ACTION", "The action "); if (!defined("_ADMIN_ACTIONS")) define("_ADMIN_ACTIONS", "Actions"); +if (!defined("_NOT_VALID")) define("_NOT_VALID", "not valid"); /************** History **************/ @@ -1007,7 +1008,7 @@ if (!defined("_ID_CONTACT_TYPE_PB")) define("_ID_CONTACT_TYPE_PB","There is a is if (!defined("_THE_CONTACT_TYPE")) define("_THE_CONTACT_TYPE","The contact type"); if (!defined("_CONTACT_TYPE_DEL")) define("_CONTACT_TYPE_DEL","Contact type deletion"); if (!defined("_DELETED_CONTACT_TYPE")) define("_DELETED_CONTACT_TYPE","Deleted contact type"); -if (!defined("_WARNING_MESSAGE_DEL_CONTACT_TYPE")) define("_WARNING_MESSAGE_DEL_CONTACT_TYPE","Warning : the contact type deletion leads to contacts reallocation to a new contact type.;"); +if (!defined("_WARNING_MESSAGE_DEL_CONTACT_TYPE")) define("_WARNING_MESSAGE_DEL_CONTACT_TYPE","Warning :<br> the contact type deletion leads to contacts reallocation to a new contact type.;"); if (!defined("_CONTACT_TYPE_REAFFECT")) define("_CONTACT_TYPE_REAFFECT","Contacts reallocation"); if (!defined("_ALL")) define("_ALL","All"); if (!defined("_CONTACT_ALREADY_CREATED")) define("_CONTACT_ALREADY_CREATED","Contacts already existing"); @@ -1029,7 +1030,7 @@ if (!defined("_THE_CONTACT_PURPOSE")) define("_THE_CONTACT_PURPOSE","The denomin if (!defined("_CONTACT_PURPOSE_DEL")) define("_CONTACT_PURPOSE_DEL","Deletion of a denomination"); if (!defined("_DELETED_CONTACT_PURPOSE")) define("_DELETED_CONTACT_PURPOSE","Deleted denomination"); if (!defined("_CONTACT_PURPOSE_REAFFECT")) define("_CONTACT_PURPOSE_REAFFECT","Addresses reallocation"); -if (!defined("_WARNING_MESSAGE_DEL_CONTACT_PURPOSE")) define("_WARNING_MESSAGE_DEL_CONTACT_PURPOSE","Warning : The denomination deletion leads to addresses reallocation to a new denomination."); +if (!defined("_WARNING_MESSAGE_DEL_CONTACT_PURPOSE")) define("_WARNING_MESSAGE_DEL_CONTACT_PURPOSE","Warning :<br> The denomination deletion leads to addresses reallocation to a new denomination."); if (!defined("_CONTACT_PURPOSE_WILL_BE_CREATED")) define("_CONTACT_PURPOSE_WILL_BE_CREATED","This denomination doesn't exist. It will automatically be created."); if (!defined("_SEARCH_CONTACTS")) define("_SEARCH_CONTACTS","Search a contact"); @@ -1898,13 +1899,6 @@ if (!defined('_UPDATED_EMAIL_SIGNATURE')) define('_UPDATED_EMAIL_SIGNATURE', 'Mail signature updated'); if (!defined('_DELETED_EMAIL_SIGNATURE')) define('_DELETED_EMAIL_SIGNATURE', 'Mail signature deleted'); - -if (!defined('_UNDEFINED_USER')) - define('_UNDEFINED_USER', 'Undefined user'); -if (!defined('_ACTIVATE_ABSENCE')) - define('_ACTIVATE_ABSENCE', 'Activate my absence'); -if (!defined('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS')) - define('_AUTO_LOGOUT_AFTER_BASKETS_REDIRECTIONS', 'You are going to be automaticaly disconnected after your redirections'); /***** Profile *****/ /**** admin update control ****/ @@ -1967,5 +1961,4 @@ if (!defined('_UPDATE_END')) if (!defined('_UPDATE_DESC_END')) define('_UPDATE_DESC_END', 'Update sucessful'); if (!defined('_NO_AVAILABLE_TAG_TO_UPDATE')) - -define('_NO_AVAILABLE_TAG_TO_UPDATE', 'No available tag to update'); \ No newline at end of file + define('_NO_AVAILABLE_TAG_TO_UPDATE', 'No available tag to update'); diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 4284aade84a6b92c5626b146b42fd5b6a2e6b2ae..7236a53a27480f9032fb410f539bbd271ec7493e 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -177,6 +177,8 @@ if (!defined("_RESSOURCES_COLLECTION")) define("_RESSOURCES_COLLECTION","Coll if (!defined("_RECIPIENT")) define("_RECIPIENT", "Destinataire"); if (!defined("_START")) define("_START", "Début"); if (!defined("_END")) define("_END", "Fin"); +if (!defined("_NOT_VALID")) define("_NOT_VALID", "non valide"); + if (!defined("_KEYWORD")) define("_KEYWORD", "Mot clé"); diff --git a/core/Controllers/ActionsController.php b/core/Controllers/ActionsController.php index 9c048ce37e3490586afeeb45e33c2171a59e16d9..1b7fe74d2f17e7d0d3cd2aa708b53877d4d1c75e 100644 --- a/core/Controllers/ActionsController.php +++ b/core/Controllers/ActionsController.php @@ -20,21 +20,19 @@ use Psr\Http\Message\ResponseInterface; use Respect\Validation\Validator; use Core\Models\ActionsModel; use Core\Models\StatusModel; +use Core\Models\LangModel; class ActionsController { - public function getList(RequestInterface $request, ResponseInterface $response) - { - $obj = ActionsModel::getList(); - - $datas = [ - $obj, - ]; + public function getForAdministration(RequestInterface $request, ResponseInterface $response){ - return $response->withJson($datas); + $obj['lang'] = LangModel::getActionsLang(); + $obj ['actions']= ActionsModel::getList(); + + return $response->withJson($obj); } - public function getById(RequestInterface $request, ResponseInterface $response, $aArgs) + public function getByIdForAdministration(RequestInterface $request, ResponseInterface $response, $aArgs) { if (isset($aArgs['id'])) { $id = $aArgs['id']; @@ -46,12 +44,16 @@ class ActionsController ->withStatus(500) ->withJson(['errors' => _ID . ' ' . _IS_EMPTY]); } - - $datas = [ - $obj, - ]; - return $response->withJson($datas); + $obj['coll_categories']=ActionsModel:: getLettersBoxCategories(); + $obj['statuts']=StatusModel::getList(); + array_unshift($obj['statuts'], ['id'=>'_NOSTATUS_','label_status'=> _UNCHANGED]); + array_unshift($obj['statuts'], ['id'=>'_NOSTATUS_','label_status'=> _CHOOSE_STATUS]); + $obj['tab_action_page']=ActionsModel::getAction_pages(); + $obj['keywords']=ActionsModel::getKeywords(); + $obj['lang'] = LangModel::getActionsLang(); + + return $response->withJson($obj); } public function create(RequestInterface $request, ResponseInterface $response, $aArgs) @@ -59,6 +61,7 @@ class ActionsController $errors = []; $aArgs = $request->getParams(); + $aArgs['is_system'] = 'N'; $errors = $this->control($aArgs, 'create'); @@ -74,7 +77,7 @@ class ActionsController if ($return) { $id = $aArgs['id']; - $obj = end(ActionsModel::getList()); + $obj = max(ActionsModel::getList()); } else { return $response ->withStatus(500) @@ -155,10 +158,7 @@ class ActionsController } if(!(in_array($aArgs['id_status'], $status))){ - $errors[]=_STATUS. ' ' . _NOT . ' ' . _VALID; - } - if (!Validator::regex('/^[\w ]+$/')->validate($aArgs['keyword'])) { - $errors[]= _KEYWORD. ' ' . _NOT . ' ' . _VALID; + $errors[]=_STATUS. ' ' . _NOT_VALID; } if ($mode == 'update') { @@ -204,4 +204,20 @@ class ActionsController return $errors; } + + public function initAction(RequestInterface $request, ResponseInterface $response) + { + $obj['history']='Y'; + $obj['is_folder_action']='N'; + $obj['coll_categories']=ActionsModel:: getLettersBoxCategories(); + $obj['statuts']=StatusModel::getList(); + array_unshift($obj['statuts'], ['id'=>'_NOSTATUS_','label_status'=> _UNCHANGED]); + array_unshift($obj['statuts'], ['id'=>'_NOSTATUS_','label_status'=> _CHOOSE_STATUS]); + $obj['tab_action_page']=ActionsModel::getAction_pages(); + $obj['keywords']=ActionsModel::getKeywords(); + $obj['lang'] = LangModel::getActionsLang(); + + return $response->withJson($obj); + + } } diff --git a/core/Models/ActionsModelAbstract.php b/core/Models/ActionsModelAbstract.php index 53974f7e14b0e3f09641d9f32ed33a5106a6d497..53c1a3550b494a965c988f758b0abb1b1a9b1c98 100644 --- a/core/Models/ActionsModelAbstract.php +++ b/core/Models/ActionsModelAbstract.php @@ -40,14 +40,33 @@ class ActionsModelAbstract extends \Apps_Table_Service 'data' => [$aArgs['id']] ]); + if(empty($aReturn[0])){ + return []; + } + + $aReturn=$aReturn[0]; + $aReturn['category_id']=static::select([ + 'select' => 'category_id', + 'table' => ['actions_categories'], + 'where' => ['action_id = ?'], + 'data' => [$aArgs['id']] + ]); + return $aReturn; } public static function create(array $aArgs = []) { - + $tmp=$aArgs['category_id']; + unset($aArgs['category_id']); $aReturn = static::insertInto($aArgs,'actions'); - + $tab['action_id']=max(ActionsModel::getList())['id']; + + for($i=0;$i<count($aArgs['category_id']);$i++) + { + $tab['category_id']=$aArgs['category_id'][$i]; + $aInsert = static::insertInto($tab,'actions_categories'); + } return $aReturn; } @@ -66,14 +85,24 @@ class ActionsModelAbstract extends \Apps_Table_Service 'history' => $aArgs['history'], 'is_folder_action' => $aArgs['is_folder_action'], 'history' => $aArgs['history'] - - - ], 'where' => ['id = ?'], 'data' => [$aArgs['id']] ]); + $aDelete = static::deleteFrom([ + 'table' => 'actions_categories', + 'where' => ['action_id = ?'], + 'data' => [$aArgs['id']] + ]); + + $tab['action_id']=$aArgs['id']; + + for($i=0;$i<count($aArgs['category_id']);$i++){ + $tab['category_id']=$aArgs['category_id'][$i]['id']; + $aInsert = static::insertInto($tab,'actions_categories'); + } + return $aReturn; } @@ -87,7 +116,122 @@ class ActionsModelAbstract extends \Apps_Table_Service 'where' => ['id = ?'], 'data' => [$aArgs['id']] ]); + $aDelete = static::deleteFrom([ + 'table' => 'actions_categories', + 'where' => ['action_id = ?'], + 'data' => [$aArgs['id']] + ]); return $aReturn; } + + public static function getLettersBoxCategories(){ + if (file_exists('custom/' .$_SESSION['custom_override_id']. '/apps/maarch_entreprise/xml/config.xml')) { + $path = 'custom/' .$_SESSION['custom_override_id']. '/apps/maarch_entreprise/xml/config.xml'; + } else { + $path = 'apps/maarch_entreprise/xml/config.xml'; + } + + $xmlfile = simplexml_load_file($path); + $categoriesTypes=[]; + $categories= $xmlfile->COLLECTION->categories; + if (count($categories) > 0) { + foreach ($categories->category as $category) { + $categoriesTmp = ['id' => (string)$category->id, 'label'=> constant((string)$category->label)]; + + if($category->id == (string)$categories->default_category){ + $categoriesTmp['default_category']=true; + + } else { + $categoriesTmp['default_category']=false; + } + $categoriesTypes[]=$categoriesTmp; + } + } + return $categoriesTypes; + + } + + public static function getAction_pages(){ + if (file_exists('custom/' .$_SESSION['custom_override_id']. '/core/xml/actions_pages.xml')) { + $path = 'custom/' .$_SESSION['custom_override_id']. '/core/xml/actions_pages.xml'; + } else { + $path = 'core/xml/actions_pages.xml'; + } + + $xmlfile = simplexml_load_file($path); + $modules=[]; + if (count($xmlfile) > 0) { + foreach ($xmlfile->ACTIONPAGE as $actions_pages) { + if(!empty($actions_pages->MODULE)){ + $modules[]=(string)$actions_pages->MODULE; + } + } + } + $modules=array_unique($modules); + $tabActions_pages=[]; + $tabActions_pages['modules']=$modules; + $tmp=[]; + + foreach ($xmlfile->ACTIONPAGE as $actions_pages) { + + if(!defined((string)$actions_pages->LABEL)){ + $label=$actions_pages->LABEL; + } + else { + $label=constant((string)$actions_pages->LABEL); + } + if(!empty($actions_pages->MODULE)){ + $tmp[]=['name' => (string)$actions_pages->NAME,'label' => $label,'module' => (string)$actions_pages->MODULE]; + } + else { + $tmp[]=['name' => (string)$actions_pages->NAME,'label' => $label,'module' => 'Apps']; + + } + } + array_unshift($tmp, ['name' => '_','label' => _NO_PAGE]); + + $tabActions_pages['actions']=$tmp; + + if (file_exists('custom/' .$_SESSION['custom_override_id']. '/modules/avis/xml/actions_pages.xml')) { + $path = 'custom/' .$_SESSION['custom_override_id']. '/modules/avis/xml/actions_pages.xml'; + } else { + $path = 'modules/avis/xml/actions_pages.xml'; + } + + $xmlfile = simplexml_load_file($path); + + $act_avis=[]; + + foreach ($xmlfile->ACTIONPAGE as $actions_pages) { + + if(!defined((string)$actions_pages->LABEL)){ + $label=$actions_pages->LABEL; + } + else { + $label=constant((string)$actions_pages->LABEL); + } + if(!empty($actions_pages->MODULE)){ + $act_avis[]=['name' => (string)$actions_pages->NAME,'label' => $label,'module' => (string)$actions_pages->MODULE]; + } + else { + $act_avis[]=['name' => (string)$actions_pages->NAME,'label' => $label,'module' => 'Apps']; + + } + } + $tabActions_pages['actions']=array_merge($tmp, $act_avis); + + return $tabActions_pages; + } + + public static function getKeywords(){ + $tabKeyword=[]; + $tabKeyword[]=['value' => '', label => _NO_KEYWORD]; + $tabKeyword[]=['value' => 'redirect', label => _REDIRECT]; + $tabKeyword[]=['value' => 'to_validate', label => _TO_VALIDATE]; + $tabKeyword[]=['value' => 'indexing', label => _INDEXING]; + $tabKeyword[]=['value' => 'workflow', label => _WF]; + + return $tabKeyword; + } } diff --git a/core/Models/LangModelAbstract.php b/core/Models/LangModelAbstract.php index 8dc050bcb03e02cf8460d871aae89ea6ff21092a..9486fd02827bed2b0ea0378bd95845831f193136 100644 --- a/core/Models/LangModelAbstract.php +++ b/core/Models/LangModelAbstract.php @@ -132,4 +132,48 @@ class LangModelAbstract return $aLang; } + + public static function getActionsLang(){ + $aLang = [ + 'id' => _ID, + 'desc' => _DESC, + 'is_folder_action' => _IS_FOLDER_ACTION, + 'is_system' => _IS_SYSTEM, + 'new_action' => _NEW_ACTION, + 'next' => _NEXT, + 'previous' => _PREVIOUS, + 'recordsPerPage' => _RECORDS_PER_PAGE, + 'display' => _DISPLAY, + 'noRecords' => _NO_RECORDS, + 'page' => _PAGE, + 'outOf' => _OUT_OF, + 'available' => _AVAILABLE, + 'filteredFrom' => _FILTERED_FROM, + 'records' => _RECORDS, + 'last' => _LAST, + 'modify' => _MODIFY, + 'delete' => _DELETE, + 'do_not_modify_unless_expert' => _DO_NOT_MODIFY_UNLESS_EXPERT, + 'associated_status' => _ASSOCIATED_STATUS, + 'yes' => _YES, + 'no' => _NO, + 'action_page' => _ACTION_PAGE, + 'action_history' => _ACTION_HISTORY, + 'choose_category_association' => _CHOOSE_CATEGORY_ASSOCIATION, + 'choose_category_association_help' => _CHOOSE_CATEGORY_ASSOCIATION_HELP, + 'add' => _ADD, + 'remove' => _REMOVE, + 'infos_actions' => _INFOS_ACTIONS, + 'keyword' => _KEYWORD, + 'system_parameters' => _SYSTEM_PARAMETERS, + 'delete_action' => _DEL_ACTION, + 'action_modified' => _ACTION_MODIFIED, + 'action_added' => _ACTION_ADDED, + 'validate' => _VALIDATE, + 'cancel' => _CANCEL, + 'search' => _SEARCH + + ]; + return $aLang; + } } diff --git a/rest/index.php b/rest/index.php index 39322704406db0f34cc808b36f97155212471414..c615befa7a2247ec5875e02c3f49aceee3f11a11 100644 --- a/rest/index.php +++ b/rest/index.php @@ -188,8 +188,9 @@ $app->get('/priorities', \Core\Controllers\PrioritiesController::class . ':getLi $app->get('/priorities/{id}', \Core\Controllers\PrioritiesController::class . ':getById'); //actions -$app->get('/actions', \Core\Controllers\ActionsController::class . ':getList'); -$app->get('/actions/{id}', \Core\Controllers\ActionsController::class . ':getById'); +$app->get('/administration/actions', \Core\Controllers\ActionsController::class . ':getForAdministration'); +$app->get('/initAction', \Core\Controllers\ActionsController::class . ':initAction'); +$app->get('/administration/actions/{id}', \Core\Controllers\ActionsController::class . ':getByIdForAdministration'); $app->post('/actions', \Core\Controllers\ActionsController::class . ':create'); $app->put('/actions/{id}', \Core\Controllers\ActionsController::class . ':update'); $app->delete('/actions/{id}', \Core\Controllers\ActionsController::class . ':delete');