function doStore() { global $doc_ged_id, $file_id, $_validation; if ($this->_obj->doc_ged_id) { // Procédure Existante --> Verification //if ($this->_old->etat == CDocGed::REDAC && $_validation === null) { if (isset($_FILES["formfile"])) { // Test d'upload du fichier $objFile = new CFileAddEdit(); $objFile->redirect = null; $objFile->doIt(); if (!CAppUI::isMsgOK()) { // Erreur sur le fichier ! if ($this->redirectError) { $this->redirect =& $this->redirectError; } $this->doRedirect(); } else { $file_id = $objFile->_obj->file_id; } } } if ($this->_old->group_id && $this->_obj->doc_chapitre_id && $this->_obj->doc_categorie_id && !$this->_old->num_ref) { // Nouvelle Procédure $this->_obj->version = 1; $where = array(); $where["num_ref"] = "IS NOT NULL"; $where["group_id"] = "= '" . $this->_old->group_id . "'"; $where["doc_chapitre_id"] = "= '" . $this->_obj->doc_chapitre_id . "'"; $where["doc_categorie_id"] = "= '" . $this->_obj->doc_categorie_id . "'"; $where["annule"] = "= '0'"; $order = "num_ref DESC"; if ($this->_obj->num_ref) { // Numérotée manuellement $where["num_ref"] = "= '" . $this->_obj->num_ref . "'"; $sameNumRef = new CDocGed(); $sameNumRef->loadObject($where, $order); if ($sameNumRef->_id) { $this->_obj->num_ref = null; } } else { // Pas de numéro : Récup n° dernier doc dans meme chapitre et catégorie $where["num_ref"] = "IS NOT NULL"; $lastNumRef = new CDocGed(); $lastNumRef->loadObject($where, $order); if (!$lastNumRef->_id) { $this->_obj->num_ref = 1; } else { $this->_obj->num_ref = $lastNumRef->num_ref + 1; } } } if (!($this->_old->etat == CDocGed::VALID && $this->_obj->etat == CDocGed::TERMINE)) { // Annulation changement de version $this->_obj->version = $this->_old->version; } if ($msg = $this->_obj->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); if ($this->redirectError) { $this->redirect =& $this->redirectError; } } else { $this->redirect = null; $doc_ged_id = $this->_obj->doc_ged_id; } }
<?php /** * $Id$ * * @category Files * @package Mediboard * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCAnDo::checkAdmin(); $object_guid = CValue::post("object_guid"); $object = CMbObject::loadFromGuid($object_guid); // Chargement de la ligne à rendre active foreach ($object->loadBackRefs("files") as $_file) { $_POST["file_id"] = $_file->_id; $_POST["del"] = "1"; $do = new CFileAddEdit(); $do->redirect = null; $do->doIt(); } echo CAppUI::getMsg(); CApp::rip();