add work
This commit is contained in:
parent
203fc77e9f
commit
2a9d38575d
@ -30,54 +30,57 @@ $langs->loadLangs(array("intracommreport"));
|
|||||||
|
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action');
|
||||||
$exporttype = GETPOST('exporttype'); // DEB ou DES
|
$exporttype = GETPOST('exporttype'); // DEB ou DES
|
||||||
if (empty($exporttype)) $exporttype = 'deb';
|
if (empty($exporttype)) {
|
||||||
|
$exporttype = 'deb';
|
||||||
|
}
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
$year = GETPOST('year');
|
$year = GETPOST('year');
|
||||||
$month = GETPOST('month');
|
$month = GETPOST('month');
|
||||||
$type_declaration = GETPOST('type');
|
$label = (string) GETPOST('label', 'alphanohtml');
|
||||||
|
$type_declaration = GETPOSTINT('type');
|
||||||
$backtopage = GETPOST('backtopage', 'alpha');
|
$backtopage = GETPOST('backtopage', 'alpha');
|
||||||
|
$declaration = array(
|
||||||
|
"deb" => $langs->trans("DEB"),
|
||||||
|
"des" => $langs->trans("DES"),
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* 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);
|
$result = $object->delete($id, $user);
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
if (!empty($backtopage)) {
|
||||||
if (!empty($backtopage))
|
|
||||||
{
|
|
||||||
header("Location: ".$backtopage);
|
header("Location: ".$backtopage);
|
||||||
exit;
|
exit;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
header("Location: list.php");
|
header("Location: list.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$errmesg = $object->error;
|
$errmesg = $object->error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'add' && $user->rights->intracommreport->write) {
|
if ($action == 'add' && $user->rights->intracommreport->write) {
|
||||||
$object->label = trim($label);
|
$object->label = trim($label);
|
||||||
$object->type = trim($type);
|
$object->type = trim($exporttype);
|
||||||
$object->type_declaration = (int) $statut;
|
$object->type_declaration = $type_declaration;
|
||||||
$object->subscription = (int) $subscription;
|
$object->subscription = (int) $subscription;
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($object->label)) {
|
if (empty($object->label)) {
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
|
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)."'";
|
$sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."adherent_type WHERE libelle='".$db->escape($object->label)."'";
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@ -90,20 +93,16 @@ if ($action == 'add' && $user->rights->intracommreport->write) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$id = $object->create($user);
|
$id = $object->create($user);
|
||||||
if ($id > 0)
|
if ($id > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,15 +112,14 @@ if ($action == 'add' && $user->rights->intracommreport->write) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Creation mode
|
// Creation mode
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
$title = $langs->trans("IntracommReportTitle");
|
$title = $langs->trans("IntracommReportTitle");
|
||||||
llxHeader("", $title);
|
llxHeader("", $title);
|
||||||
print load_fiche_titre($langs->trans("IntracommReportTitle"));
|
print load_fiche_titre($langs->trans("IntracommReportTitle"));
|
||||||
|
|
||||||
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form name="charge" method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="export" />';
|
print '<input type="hidden" name="action" value="add" />';
|
||||||
|
|
||||||
print dol_get_fiche_head();
|
print dol_get_fiche_head();
|
||||||
|
|
||||||
@ -131,10 +129,8 @@ if ($action == 'create')
|
|||||||
print '<tr><td class="titlefieldcreate">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
|
print '<tr><td class="titlefieldcreate">'.$langs->trans("Label").'</td><td><input type="text" class="minwidth200" name="label" autofocus="autofocus"></td></tr>';
|
||||||
|
|
||||||
// Declaration
|
// Declaration
|
||||||
$declaration["deb"] = $langs->trans("DEB");
|
|
||||||
$declaration["des"] = $langs->trans("DES");
|
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Declaration")."</td><td>\n";
|
print '<tr><td class="fieldrequired">'.$langs->trans("Declaration")."</td><td>\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 "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
// Analysis period
|
// Analysis period
|
||||||
@ -179,8 +175,8 @@ if ($id > 0 && $action != 'edit') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show tabs
|
* 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($head, 'general', $langs->trans("IntracommReport"), -1, 'user');
|
||||||
@ -195,8 +191,15 @@ if ($id > 0 && $action != 'edit') {
|
|||||||
'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])
|
'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteReport"),
|
print $form->formconfirm(
|
||||||
$langs->trans("ConfirmDeleteReport"), "confirm_delete", $formquestion, 'no', 1);
|
"card.php?rowid=".$id,
|
||||||
|
$langs->trans("DeleteReport"),
|
||||||
|
$langs->trans("ConfirmDeleteReport"),
|
||||||
|
"confirm_delete",
|
||||||
|
$formquestion,
|
||||||
|
'no',
|
||||||
|
1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/intracommreport/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/intracommreport/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
@ -229,101 +232,101 @@ if ($id > 0 && $action != 'edit') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
switch($action) {
|
switch($action) {
|
||||||
case 'generateXML':
|
case 'generateXML':
|
||||||
$obj = new TDebProdouane($PDOdb);
|
$obj = new TDebProdouane($PDOdb);
|
||||||
$obj->load($PDOdb, GETPOST('id_declaration'));
|
$obj->load($PDOdb, GETPOST('id_declaration'));
|
||||||
$obj->generateXMLFile();
|
$obj->generateXMLFile();
|
||||||
break;
|
break;
|
||||||
case 'list':
|
case 'list':
|
||||||
_liste($exporttype);
|
_liste($exporttype);
|
||||||
break;
|
break;
|
||||||
case 'export':
|
case 'export':
|
||||||
if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
|
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));
|
else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT));
|
||||||
default:
|
default:
|
||||||
if ($exporttype == 'deb') _print_form_deb();
|
if ($exporttype == 'deb') _print_form_deb();
|
||||||
else _print_form_des();
|
else _print_form_des();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _print_form_des()
|
function _print_form_des()
|
||||||
{
|
{
|
||||||
global $langs, $formother, $year, $month, $type_declaration;
|
global $langs, $formother, $year, $month, $type_declaration;
|
||||||
|
|
||||||
$title = $langs->trans("IntracommReportDESTitle");
|
$title = $langs->trans("IntracommReportDESTitle");
|
||||||
llxHeader("", $title);
|
llxHeader("", $title);
|
||||||
print load_fiche_titre($langs->trans("IntracommReportDESTitle"));
|
print load_fiche_titre($langs->trans("IntracommReportDESTitle"));
|
||||||
|
|
||||||
print dol_get_fiche_head();
|
print dol_get_fiche_head();
|
||||||
|
|
||||||
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
|
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="export" />';
|
print '<input type="hidden" name="action" value="export" />';
|
||||||
print '<input type="hidden" name="exporttype" value="des" />';
|
print '<input type="hidden" name="exporttype" value="des" />';
|
||||||
print '<input type="hidden" name="type" value="expedition" />'; // Permet d'utiliser le bon select de la requête sql
|
print '<input type="hidden" name="type" value="expedition" />'; // Permet d'utiliser le bon select de la requête sql
|
||||||
|
|
||||||
print '<table width="100%" class="noborder">';
|
print '<table width="100%" class="noborder">';
|
||||||
|
|
||||||
print '<tr class="liste_titre"><td colspan="2">';
|
print '<tr class="liste_titre"><td colspan="2">';
|
||||||
print 'Paramètres de l\'export';
|
print 'Paramètres de l\'export';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>Période d\'analyse</td>';
|
print '<td>Période d\'analyse</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$TabMonth = array();
|
$TabMonth = array();
|
||||||
for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT));
|
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 $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month);
|
||||||
print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5);
|
print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print '<input class="butAction" type="submit" value="Exporter XML" />';
|
print '<input class="butAction" type="submit" value="Exporter XML" />';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = new TDebProdouane($db);
|
||||||
$obj->entity = $conf->entity;
|
$obj->entity = $conf->entity;
|
||||||
$obj->mode = 'O';
|
$obj->mode = 'O';
|
||||||
$obj->periode = $period_year.'-'.$period_month;
|
$obj->periode = $period_year.'-'.$period_month;
|
||||||
$obj->type_declaration = $type_declaration;
|
$obj->type_declaration = $type_declaration;
|
||||||
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
|
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
|
||||||
$obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month);
|
$obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month);
|
||||||
if(empty($obj->errors)) {
|
if(empty($obj->errors)) {
|
||||||
$obj->save($PDOdb);
|
$obj->save($PDOdb);
|
||||||
$obj->generateXMLFile();
|
$obj->generateXMLFile();
|
||||||
}
|
}
|
||||||
else setEventMessage($obj->errors, 'warnings');
|
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 = new TDebProdouane($PDOdb);
|
||||||
$obj->entity = $conf->entity;
|
$obj->entity = $conf->entity;
|
||||||
$obj->periode = $period_year.'-'.$period_month;
|
$obj->periode = $period_year.'-'.$period_month;
|
||||||
$obj->type_declaration = $type_declaration;
|
$obj->type_declaration = $type_declaration;
|
||||||
$obj->exporttype = 'des';
|
$obj->exporttype = 'des';
|
||||||
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
|
$obj->numero_declaration = $obj->getNextNumeroDeclaration();
|
||||||
$obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration);
|
$obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration);
|
||||||
if(empty($obj->errors)) {
|
if(empty($obj->errors)) {
|
||||||
$obj->save($PDOdb);
|
$obj->save($PDOdb);
|
||||||
$obj->generateXMLFile();
|
$obj->generateXMLFile();
|
||||||
}
|
}
|
||||||
else setEventMessage($obj->errors, 'warnings');
|
else setEventMessage($obj->errors, 'warnings');
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user