From 2a9d38575db67a054282a79cbcd4953d51387f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 13 Dec 2020 10:51:12 +0100 Subject: [PATCH] add work --- htdocs/intracommreport/card.php | 233 ++++++++++++++++---------------- 1 file changed, 118 insertions(+), 115 deletions(-) diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 668eca12674..f0a4bd5f070 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -30,54 +30,57 @@ $langs->loadLangs(array("intracommreport")); $action = GETPOST('action'); $exporttype = GETPOST('exporttype'); // DEB ou DES -if (empty($exporttype)) $exporttype = 'deb'; +if (empty($exporttype)) { + $exporttype = 'deb'; +} $form = new Form($db); $formother = new FormOther($db); $year = GETPOST('year'); $month = GETPOST('month'); -$type_declaration = GETPOST('type'); +$label = (string) GETPOST('label', 'alphanohtml'); +$type_declaration = GETPOSTINT('type'); $backtopage = GETPOST('backtopage', 'alpha'); +$declaration = array( + "deb" => $langs->trans("DEB"), + "des" => $langs->trans("DES"), +); /* * Actions */ -if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') -{ +if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') { $result = $object->delete($id, $user); - if ($result > 0) - { - if (!empty($backtopage)) - { + if ($result > 0) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; - } - else { + } else { header("Location: list.php"); exit; } - } - else { + } else { $errmesg = $object->error; } } if ($action == 'add' && $user->rights->intracommreport->write) { $object->label = trim($label); - $object->type = trim($type); - $object->type_declaration = (int) $statut; - $object->subscription = (int) $subscription; + $object->type = trim($exporttype); + $object->type_declaration = $type_declaration; + $object->subscription = (int) $subscription; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) $error++; + if ($ret < 0) { + $error++; + } if (empty($object->label)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); - } - else { + } else { $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'"; $result = $db->query($sql); if ($result) { @@ -90,20 +93,16 @@ if ($action == 'add' && $user->rights->intracommreport->write) { } } - if (!$error) - { + if (!$error) { $id = $object->create($user); - if ($id > 0) - { + if ($id > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; - } - else { + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } - } - else { + } else { $action = 'create'; } } @@ -113,15 +112,14 @@ if ($action == 'add' && $user->rights->intracommreport->write) { */ // Creation mode -if ($action == 'create') -{ +if ($action == 'create') { $title = $langs->trans("IntracommReportTitle"); llxHeader("", $title); print load_fiche_titre($langs->trans("IntracommReportTitle")); print '
'; print ''; - print ''; + print ''; print dol_get_fiche_head(); @@ -131,10 +129,8 @@ if ($action == 'create') print ''.$langs->trans("Label").''; // Declaration - $declaration["deb"] = $langs->trans("DEB"); - $declaration["des"] = $langs->trans("DES"); print ''.$langs->trans("Declaration")."\n"; - print $form->selectarray("declaration", $declaration, GETPOST('declaration', 'alpha') ?GETPOST('declaration', 'alpha') : $object->declaration, 0); + print $form->selectarray("declaration", $declaration, GETPOST('declaration', 'alpha') ? GETPOST('declaration', 'alpha') : $object->declaration, 0); print "\n"; // Analysis period @@ -179,8 +175,8 @@ if ($id > 0 && $action != 'edit') { } /* - * Show tabs - */ + * Show tabs + */ $head = intracommreport_prepare_head($object); print dol_get_fiche_head($head, 'general', $langs->trans("IntracommReport"), -1, 'user'); @@ -195,8 +191,15 @@ if ($id > 0 && $action != 'edit') { 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]) ); } - print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteReport"), - $langs->trans("ConfirmDeleteReport"), "confirm_delete", $formquestion, 'no', 1); + print $form->formconfirm( + "card.php?rowid=".$id, + $langs->trans("DeleteReport"), + $langs->trans("ConfirmDeleteReport"), + "confirm_delete", + $formquestion, + 'no', + 1 + ); } $linkback = ''.$langs->trans("BackToList").''; @@ -229,101 +232,101 @@ if ($id > 0 && $action != 'edit') { } /* - switch($action) { - case 'generateXML': - $obj = new TDebProdouane($PDOdb); - $obj->load($PDOdb, GETPOST('id_declaration')); - $obj->generateXMLFile(); - break; - case 'list': - _liste($exporttype); - break; - case 'export': - if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT)); - else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT)); - default: - if ($exporttype == 'deb') _print_form_deb(); - else _print_form_des(); - break; - } + switch($action) { + case 'generateXML': + $obj = new TDebProdouane($PDOdb); + $obj->load($PDOdb, GETPOST('id_declaration')); + $obj->generateXMLFile(); + break; + case 'list': + _liste($exporttype); + break; + case 'export': + if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT)); + else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT)); + default: + if ($exporttype == 'deb') _print_form_deb(); + else _print_form_des(); + break; + } - function _print_form_des() - { - global $langs, $formother, $year, $month, $type_declaration; + function _print_form_des() + { + global $langs, $formother, $year, $month, $type_declaration; - $title = $langs->trans("IntracommReportDESTitle"); - llxHeader("", $title); - print load_fiche_titre($langs->trans("IntracommReportDESTitle")); + $title = $langs->trans("IntracommReportDESTitle"); + llxHeader("", $title); + print load_fiche_titre($langs->trans("IntracommReportDESTitle")); - print dol_get_fiche_head(); + print dol_get_fiche_head(); - print ''; - print ''; - print ''; - print ''; - print ''; // Permet d'utiliser le bon select de la requête sql + print ''; + print ''; + print ''; + print ''; + print ''; // Permet d'utiliser le bon select de la requête sql - print ''; + print '
'; - print ''; + print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print '
'; - print 'Paramètres de l\'export'; - print '
'; + print 'Paramètres de l\'export'; + print '
Période d\'analyse'; - $TabMonth = array(); - for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT)); - //print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month); - print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5); - print '
Période d\'analyse'; + $TabMonth = array(); + for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT)); + //print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month); + print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5); + print '
'; + print ''; - print '
'; - print ''; - print '
'; + print '
'; + print ''; + print '
'; - print '
'; - } + print ''; + } - function _export_xml_deb($type_declaration, $period_year, $period_month) { + function _export_xml_deb($type_declaration, $period_year, $period_month) { - global $db, $conf; + global $db, $conf; - $obj = new TDebProdouane($db); - $obj->entity = $conf->entity; - $obj->mode = 'O'; - $obj->periode = $period_year.'-'.$period_month; - $obj->type_declaration = $type_declaration; - $obj->numero_declaration = $obj->getNextNumeroDeclaration(); - $obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month); - if(empty($obj->errors)) { - $obj->save($PDOdb); - $obj->generateXMLFile(); - } - else setEventMessage($obj->errors, 'warnings'); - } + $obj = new TDebProdouane($db); + $obj->entity = $conf->entity; + $obj->mode = 'O'; + $obj->periode = $period_year.'-'.$period_month; + $obj->type_declaration = $type_declaration; + $obj->numero_declaration = $obj->getNextNumeroDeclaration(); + $obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month); + if(empty($obj->errors)) { + $obj->save($PDOdb); + $obj->generateXMLFile(); + } + else setEventMessage($obj->errors, 'warnings'); + } - function _export_xml_des($type_declaration, $period_year, $period_month) { + function _export_xml_des($type_declaration, $period_year, $period_month) { - global $PDOdb, $conf; + global $PDOdb, $conf; - $obj = new TDebProdouane($PDOdb); - $obj->entity = $conf->entity; - $obj->periode = $period_year.'-'.$period_month; - $obj->type_declaration = $type_declaration; - $obj->exporttype = 'des'; - $obj->numero_declaration = $obj->getNextNumeroDeclaration(); - $obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration); - if(empty($obj->errors)) { - $obj->save($PDOdb); - $obj->generateXMLFile(); - } - else setEventMessage($obj->errors, 'warnings'); - } - */ + $obj = new TDebProdouane($PDOdb); + $obj->entity = $conf->entity; + $obj->periode = $period_year.'-'.$period_month; + $obj->type_declaration = $type_declaration; + $obj->exporttype = 'des'; + $obj->numero_declaration = $obj->getNextNumeroDeclaration(); + $obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration); + if(empty($obj->errors)) { + $obj->save($PDOdb); + $obj->generateXMLFile(); + } + else setEventMessage($obj->errors, 'warnings'); + } + */ // End of page llxFooter();