From 44d3bc2e646292a09d858a7ba73d1679b82ec24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Dec 2020 08:39:08 +0100 Subject: [PATCH] add work --- htdocs/intracommreport/card.php | 55 +++++++++++-------- .../class/intracommreport.class.php | 47 +++++++++++++--- htdocs/intracommreport/list.php | 4 +- 3 files changed, 75 insertions(+), 31 deletions(-) diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index f0a4bd5f070..077f793d649 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -27,28 +27,41 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php'; $langs->loadLangs(array("intracommreport")); - +var_dump($_POST); $action = GETPOST('action'); -$exporttype = GETPOST('exporttype'); // DEB ou DES -if (empty($exporttype)) { - $exporttype = 'deb'; -} - -$form = new Form($db); -$formother = new FormOther($db); -$year = GETPOST('year'); -$month = GETPOST('month'); +$exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB ou DES +$year = GETPOSTINT('year'); +$month = GETPOSTINT('month'); $label = (string) GETPOST('label', 'alphanohtml'); -$type_declaration = GETPOSTINT('type'); +$type_declaration = (string) GETPOST('type_declaration', 'alphanohtml'); $backtopage = GETPOST('backtopage', 'alpha'); $declaration = array( "deb" => $langs->trans("DEB"), "des" => $langs->trans("DES"), ); +$typeOfDeclaration = array( + "introduction" => $langs->trans("Introduction"), + "expedition" => $langs->trans("Expedition"), +); +$object = new IntracommReport($db); +if ($id > 0) { + $object->fetch($id); +} +$form = new Form($db); +$formother = new FormOther($db); + +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('intracommcard', 'globalcard')); /* * Actions */ +$parameters = array('id' => $id); +// Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') { $result = $object->delete($id, $user); @@ -72,16 +85,16 @@ if ($action == 'add' && $user->rights->intracommreport->write) { $object->subscription = (int) $subscription; // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error++; - } + // $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + // if ($ret < 0) { + // $error++; + // } if (empty($object->label)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } else { - $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."intracommreport WHERE ref='".$db->escape($object->label)."'"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); @@ -96,7 +109,7 @@ if ($action == 'add' && $user->rights->intracommreport->write) { if (!$error) { $id = $object->create($user); if ($id > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -145,10 +158,8 @@ if ($action == 'create') { print ''; // Type of declaration - $typeOfDeclaration["introduction"] = $langs->trans("Introduction"); - $typeOfDeclaration["expedition"] = $langs->trans("Expedition"); print ''.$langs->trans("TypeOfDeclaration")."\n"; - print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha') ?GETPOST('type_declaration', 'alpha') : $object->type_declaration, 0); + print $form->selectarray("type_declaration", $typeOfDeclaration, GETPOST('type_declaration', 'alpha') ? GETPOST('type_declaration', 'alpha') : $object->type_declaration, 0); print "\n"; print ''; @@ -177,9 +188,9 @@ if ($id > 0 && $action != 'edit') { /* * Show tabs */ - $head = intracommreport_prepare_head($object); + //$head = intracommreport_prepare_head($object); - print dol_get_fiche_head($head, 'general', $langs->trans("IntracommReport"), -1, 'user'); + print dol_get_fiche_head("", 'general', $langs->trans("IntracommReport"), -1, 'user'); // Confirm remove report if ($action == 'delete') { diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index d1145dcf806..0cf5a71c27a 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -81,13 +81,46 @@ class IntracommReport extends CommonObject $this->exporttype = 'deb'; } + /** + * Fonction create + * @param User $user User + * @param int $notrigger notrigger + * @return int + */ + public function create($user, $notrigger = 0) + { + return 1; + } + + /** + * Fonction fetch + * @param int $id object ID + * @return int + */ + public function fetch($id) + { + return 1; + } + + /** + * Fonction delete + * @param int $id object ID + * @param User $user User + * @param int $notrigger notrigger + * @return int + */ + public function delete($id, $user, $notrigger = 0) + { + return 1; + } + /** * Generate XML file * - * @param int $mode O for create, R for regenerate (Look always 0 ment toujours 0 within the framework of XML exchanges according to documentation) - * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) - * @param string $period_reference Period of reference - * @return void + * @param int $mode O for create, R for regenerate (Look always 0 ment toujours 0 within the framework of XML exchanges according to documentation) + * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) + * @param string $period_reference Period of reference + * @return SimpleXMLElement|int */ public function getXML($mode = 'O', $type = 'introduction', $period_reference = '') { @@ -149,7 +182,7 @@ class IntracommReport extends CommonObject * @param int $period_year Year of declaration * @param int $period_month Month of declaration * @param string $type_declaration Declaration type by default - introduction or expedition (always 'expedition' for Des) - * @return void + * @return SimpleXMLElement|int */ public function getXMLDes($period_year, $period_month, $type_declaration = 'expedition') { @@ -246,7 +279,7 @@ class IntracommReport extends CommonObject * @param string $type Declaration type by default - introduction or expedition (always 'expedition' for Des) * @param int $period_reference Reference declaration * @param string $exporttype deb=DEB, des=DES - * @return int <0 if KO, >0 if OK + * @return string <0 if KO, >0 if OK */ public function getSQLFactLines($type, $period_reference, $exporttype = 'deb') { @@ -325,7 +358,7 @@ class IntracommReport extends CommonObject * Add item for DES * * @param SimpleXMLElement $declaration Reference declaration - * @param esurce $res Result of request SQL + * @param Resource $res Result of request SQL * @param int $i Line Id * @return void */ diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index 1530e07d84e..d3346e344f4 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -121,8 +121,8 @@ $isInEEC = isInEEC($mysoc); // Definition of fields for lists $arrayfields = array( - 'i.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'i.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'i.ref' => array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'i.label' => array('label'=>$langs->trans("Label"), 'checked'=>1), 'i.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(!empty($conf->produit->enabled) && !empty($conf->service->enabled))), ); /*