140 |
if ($this->getVal('stream') == "output") { |
if ($this->getVal('stream') == "output") { |
141 |
$form->setVal('json_payload', $this->view_form_json(true)); |
$form->setVal('json_payload', $this->view_form_json(true)); |
142 |
} else { |
} else { |
143 |
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
if ($this->getVal('type') == 'ajout_piece'){ |
144 |
|
// On modifie la valeur du champ "file_content" afin de tronquer le base64 |
145 |
|
$json_payload = json_decode($this->getVal("json_payload"), true); |
146 |
|
$json_payload["document_numerise"]["file_content"] = substr($json_payload["document_numerise"]["file_content"], 0, 64)."[...]"; |
147 |
|
$json_payload_result = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); |
148 |
|
$form->setVal('json_payload', htmlentities($json_payload_result)); |
149 |
|
} else { |
150 |
|
// |
151 |
|
$form->setVal('json_payload', htmlentities($this->getVal('json_payload'))); |
152 |
|
} |
153 |
} |
} |
154 |
} |
} |
155 |
|
|
156 |
|
function setLib(&$form, $maj) { |
157 |
|
parent::setLib($form, $maj); |
158 |
|
$form->setLib('json_payload', ''); |
159 |
|
} |
160 |
|
|
161 |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
public function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
162 |
parent::verifier($val, $dnu1, $dnu2); |
parent::verifier($val, $dnu1, $dnu2); |
163 |
// |
// |
215 |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
'stream' => isset($params['val']['stream']) === true ? $params['val']['stream'] : 'output', |
216 |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
'json_payload' => isset($params['val']['json_payload']) === true ? $params['val']['json_payload'] : '{}', |
217 |
); |
); |
218 |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
if($valF["stream"] != "input"){ |
219 |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
$task_exists = $this->task_exists($valF['type'], $valF['object_id']); |
220 |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
if ($valF['type'] === 'modification_DI' && $task_exists === false) { |
221 |
} |
$task_exists = $this->task_exists('creation_DI', $valF['object_id']); |
222 |
if ($task_exists !== false) { |
} |
223 |
$inst_task = $this->f->get_inst__om_dbform(array( |
if ($task_exists !== false) { |
224 |
"obj" => "task", |
$inst_task = $this->f->get_inst__om_dbform(array( |
225 |
"idx" => $task_exists, |
"obj" => "task", |
226 |
)); |
"idx" => $task_exists, |
227 |
$update_state = $inst_task->getVal('state'); |
)); |
228 |
if (isset($params['update_val']['state']) === true) { |
$update_state = $inst_task->getVal('state'); |
229 |
$update_state = $params['update_val']['state']; |
if (isset($params['update_val']['state']) === true) { |
230 |
} |
$update_state = $params['update_val']['state']; |
231 |
$update_params = array( |
} |
232 |
'val' => array( |
$update_params = array( |
233 |
'state' => $update_state, |
'val' => array( |
234 |
), |
'state' => $update_state, |
235 |
); |
), |
236 |
return $inst_task->update_task($update_params); |
); |
237 |
|
return $inst_task->update_task($update_params); |
238 |
|
} |
239 |
} |
} |
240 |
$add = $this->ajouter($valF); |
$add = $this->ajouter($valF); |
241 |
if ($add === false) { |
if ($add === false) { |
736 |
} |
} |
737 |
|
|
738 |
if ($in_field === true) { |
if ($in_field === true) { |
739 |
return json_encode($val, JSON_PRETTY_PRINT ,JSON_UNESCAPED_SLASHES); |
return json_encode($val, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
740 |
} else { |
} else { |
741 |
// Liste des valeurs affichée en JSON |
// Liste des valeurs affichée en JSON |
742 |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
printf(json_encode($val, JSON_UNESCAPED_SLASHES)); |
794 |
function view_add_json_data() { |
function view_add_json_data() { |
795 |
$params = array(); |
$params = array(); |
796 |
$params['val']['stream'] = 'input'; |
$params['val']['stream'] = 'input'; |
|
$params['val']['type'] = $this->f->get_submitted_post_value('type'); |
|
|
$params['val']['object_id'] = $this->f->get_submitted_post_value('object_id'); |
|
|
$params['val']['dossier'] = $this->f->get_submitted_post_value('dossier'); |
|
797 |
$params['val']['json_payload'] = $this->f->get_submitted_post_value('json_payload'); |
$params['val']['json_payload'] = $this->f->get_submitted_post_value('json_payload'); |
798 |
|
$json_payload = json_decode($params['val']['json_payload'], true); |
799 |
|
$params['val']['type'] = $json_payload['task']['type']; |
800 |
|
$params['val']['dossier'] = $json_payload['task']['dossier']; |
801 |
|
$params['val']['object_id'] = ""; |
802 |
|
if ($params['val']['type'] == 'ajout_piece') { |
803 |
|
$document_numerise = $json_payload['document_numerise']; |
804 |
|
$file_content = base64_decode($document_numerise["file_content"]); |
805 |
|
if ($file_content === false){ |
806 |
|
$this->addToMessage(__("Le contenu du fichier lié à la tâche n'a pas pu etre recupere.")); |
807 |
|
return false; |
808 |
|
} |
809 |
|
$metadata = array( |
810 |
|
"filename" => $document_numerise['nom_fichier'], |
811 |
|
"size" => strlen($file_content), |
812 |
|
"mimetype" => $document_numerise['file_content_type'], |
813 |
|
"date_creation" => $document_numerise['date_creation'], |
814 |
|
); |
815 |
|
$uid_fichier = $this->f->storage->create($file_content, $metadata, "from_content"); |
816 |
|
if ($uid_fichier === OP_FAILURE) { |
817 |
|
$this->addToMessage(__("Erreur lors de la creation du fichier lié à la tâche.")); |
818 |
|
return false; |
819 |
|
} |
820 |
|
$json_payload["document_numerise"]["uid"] = $uid_fichier; |
821 |
|
$params['val']['json_payload'] = json_encode($json_payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); |
822 |
|
} |
823 |
$this->add_task($params); |
$this->add_task($params); |
824 |
} |
} |
825 |
|
|
847 |
|
|
848 |
function setLayout(&$form, $maj) { |
function setLayout(&$form, $maj) { |
849 |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
$form->setBloc('json_payload', 'D', '', 'col_6'); |
850 |
$form->setFieldset('json_payload', 'DF', _("json_payload"), "collapsible, startClosed"); |
$form->setFieldset('json_payload', 'DF', __("json_payload"), "collapsible, startClosed"); |
851 |
$form->setBloc('json_payload', 'F'); |
$form->setBloc('json_payload', 'F'); |
852 |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
$form->setBloc('timestamp_log', 'DF', '', 'col_9'); |
853 |
} |
} |