This commit is contained in:
Frédéric FRANCE 2020-12-14 08:39:08 +01:00
parent 2a9d38575d
commit 44d3bc2e64
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 75 additions and 31 deletions

View File

@ -27,28 +27,41 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php'; require_once DOL_DOCUMENT_ROOT.'/intracommreport/class/intracommreport.class.php';
$langs->loadLangs(array("intracommreport")); $langs->loadLangs(array("intracommreport"));
var_dump($_POST);
$action = GETPOST('action'); $action = GETPOST('action');
$exporttype = GETPOST('exporttype'); // DEB ou DES $exporttype = GETPOSTISSET('exporttype') ? GETPOST('exporttype', 'alphanohtml') : 'deb'; // DEB ou DES
if (empty($exporttype)) { $year = GETPOSTINT('year');
$exporttype = 'deb'; $month = GETPOSTINT('month');
}
$form = new Form($db);
$formother = new FormOther($db);
$year = GETPOST('year');
$month = GETPOST('month');
$label = (string) GETPOST('label', 'alphanohtml'); $label = (string) GETPOST('label', 'alphanohtml');
$type_declaration = GETPOSTINT('type'); $type_declaration = (string) GETPOST('type_declaration', 'alphanohtml');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$declaration = array( $declaration = array(
"deb" => $langs->trans("DEB"), "deb" => $langs->trans("DEB"),
"des" => $langs->trans("DES"), "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 * 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') { if ($user->rights->intracommreport->delete && $action == 'confirm_delete' && $confirm == 'yes') {
$result = $object->delete($id, $user); $result = $object->delete($id, $user);
@ -72,16 +85,16 @@ if ($action == 'add' && $user->rights->intracommreport->write) {
$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) { // if ($ret < 0) {
$error++; // $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 rowid FROM ".MAIN_DB_PREFIX."intracommreport WHERE ref='".$db->escape($object->label)."'";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@ -96,7 +109,7 @@ 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"].'?id='.$id);
exit; exit;
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -145,10 +158,8 @@ if ($action == 'create') {
print '</tr>'; print '</tr>';
// Type of declaration // Type of declaration
$typeOfDeclaration["introduction"] = $langs->trans("Introduction");
$typeOfDeclaration["expedition"] = $langs->trans("Expedition");
print '<tr><td class="fieldrequired">'.$langs->trans("TypeOfDeclaration")."</td><td>\n"; print '<tr><td class="fieldrequired">'.$langs->trans("TypeOfDeclaration")."</td><td>\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 "</td>\n"; print "</td>\n";
print '</table>'; print '</table>';
@ -177,9 +188,9 @@ 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("", 'general', $langs->trans("IntracommReport"), -1, 'user');
// Confirm remove report // Confirm remove report
if ($action == 'delete') { if ($action == 'delete') {

View File

@ -81,13 +81,46 @@ class IntracommReport extends CommonObject
$this->exporttype = 'deb'; $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 * 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 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 $type Declaration type by default - introduction or expedition (always 'expedition' for Des)
* @param string $period_reference Period of reference * @param string $period_reference Period of reference
* @return void * @return SimpleXMLElement|int
*/ */
public function getXML($mode = 'O', $type = 'introduction', $period_reference = '') 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_year Year of declaration
* @param int $period_month Month of declaration * @param int $period_month Month of declaration
* @param string $type_declaration Declaration type by default - introduction or expedition (always 'expedition' for Des) * @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') 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 string $type Declaration type by default - introduction or expedition (always 'expedition' for Des)
* @param int $period_reference Reference declaration * @param int $period_reference Reference declaration
* @param string $exporttype deb=DEB, des=DES * @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') public function getSQLFactLines($type, $period_reference, $exporttype = 'deb')
{ {
@ -325,7 +358,7 @@ class IntracommReport extends CommonObject
* Add item for DES * Add item for DES
* *
* @param SimpleXMLElement $declaration Reference declaration * @param SimpleXMLElement $declaration Reference declaration
* @param esurce $res Result of request SQL * @param Resource $res Result of request SQL
* @param int $i Line Id * @param int $i Line Id
* @return void * @return void
*/ */

View File

@ -121,8 +121,8 @@ $isInEEC = isInEEC($mysoc);
// Definition of fields for lists // Definition of fields for lists
$arrayfields = array( $arrayfields = array(
'i.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), 'i.ref' => array('label'=>$langs->trans("Ref"), 'checked'=>1),
'i.label'=>array('label'=>$langs->trans("Label"), '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))), 'i.fk_product_type'=>array('label'=>$langs->trans("Type"), 'checked'=>0, 'enabled'=>(!empty($conf->produit->enabled) && !empty($conf->service->enabled))),
); );
/* /*