FIX #26944
This commit is contained in:
parent
ef018a849e
commit
bd2e2c5c75
4 changed files with 20 additions and 100 deletions
|
|
@ -201,6 +201,7 @@ if (empty($reshook)) {
|
|||
$object->label = GETPOST('label', 'alpha');
|
||||
$object->date_ech = $dateech;
|
||||
$object->periode = $dateperiod;
|
||||
$object->period = $dateperiod;
|
||||
$object->amount = $amount;
|
||||
$object->fk_user = $fk_user;
|
||||
$object->mode_reglement_id = (int) GETPOST('mode_reglement_id', 'int');
|
||||
|
|
@ -236,6 +237,7 @@ if (empty($reshook)) {
|
|||
|
||||
$object->date_ech = $dateech;
|
||||
$object->periode = $dateperiod;
|
||||
$object->period = $dateperiod;
|
||||
$object->amount = $amount;
|
||||
$object->fk_user = $fk_user;
|
||||
|
||||
|
|
@ -271,6 +273,7 @@ if (empty($reshook)) {
|
|||
|
||||
if (GETPOST('clone_for_next_month', 'int')) { // This can be true only if TAX_ADD_CLONE_FOR_NEXT_MONTH_CHECKBOX has been set
|
||||
$object->periode = dol_time_plus_duree($object->periode, 1, 'm');
|
||||
$object->period = dol_time_plus_duree($object->periode, 1, 'm');
|
||||
$object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
|
||||
} else {
|
||||
// Note date_ech is often a little bit higher than dateperiod
|
||||
|
|
@ -278,6 +281,7 @@ if (empty($reshook)) {
|
|||
$newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int'));
|
||||
if ($newdateperiod) {
|
||||
$object->periode = $newdateperiod;
|
||||
$object->period = $newdateperiod;
|
||||
if (empty($newdateech)) {
|
||||
$object->date_ech = $object->periode;
|
||||
}
|
||||
|
|
@ -288,6 +292,7 @@ if (empty($reshook)) {
|
|||
// TODO We can here get dol_get_last_day of previous month:
|
||||
// $object->periode = dol_get_last_day(year of $object->date_ech - 1m, month or $object->date_ech -1m)
|
||||
$object->periode = $object->date_ech;
|
||||
$object->period = $object->date_ech;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,11 @@ class ChargeSociales extends CommonObject
|
|||
public $type_label;
|
||||
public $amount;
|
||||
public $paye;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public $periode;
|
||||
public $period;
|
||||
|
||||
/**
|
||||
* @var integer|string date_creation
|
||||
|
|
@ -149,7 +153,7 @@ class ChargeSociales extends CommonObject
|
|||
public function fetch($id, $ref = '')
|
||||
{
|
||||
$sql = "SELECT cs.rowid, cs.date_ech";
|
||||
$sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key";
|
||||
$sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode as period, cs.import_key";
|
||||
$sql .= ", cs.fk_account, cs.fk_mode_reglement, cs.fk_user, note_public, note_private";
|
||||
$sql .= ", c.libelle as type_label";
|
||||
$sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
|
||||
|
|
@ -186,7 +190,8 @@ class ChargeSociales extends CommonObject
|
|||
$this->note_public = $obj->note_public;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->paye = $obj->paye;
|
||||
$this->periode = $this->db->jdate($obj->periode);
|
||||
$this->periode = $this->db->jdate($obj->period);
|
||||
$this->period = $this->db->jdate($obj->period);
|
||||
$this->import_key = $this->import_key;
|
||||
|
||||
$this->db->free($resql);
|
||||
|
|
@ -211,7 +216,7 @@ class ChargeSociales extends CommonObject
|
|||
$newamount = price2num($this->amount, 'MT');
|
||||
|
||||
// Validation of parameters
|
||||
if ($newamount == 0 || empty($this->date_ech) || empty($this->periode)) {
|
||||
if ($newamount == 0 || empty($this->date_ech) || (empty($this->period) && empty($this->periode))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -744,6 +749,7 @@ class ChargeSociales extends CommonObject
|
|||
$this->date_creation = dol_now();
|
||||
$this->date_ech = $this->date_creation + 3600 * 24 * 30;
|
||||
$this->periode = $this->date_creation + 3600 * 24 * 30;
|
||||
$this->period = $this->date_creation + 3600 * 24 * 30;
|
||||
$this->amount = 100;
|
||||
$this->label = 'Social contribution label';
|
||||
$this->type = 1;
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ if ($id > 0 && $action != 'edit') {
|
|||
// Type
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td class="valeur">'.$object->declaration."</td></tr>\n";
|
||||
|
||||
// Analysis Period
|
||||
// Analysis period
|
||||
print '<tr><td>'.$langs->trans("AnalysisPeriod").'</td><td class="valeur">'.$object->period.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
|
@ -283,101 +283,6 @@ if ($id > 0 && $action != 'edit') {
|
|||
print dol_get_fiche_end();
|
||||
}
|
||||
|
||||
/*
|
||||
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;
|
||||
|
||||
print load_fiche_titre($langs->trans("IntracommReportDESTitle"));
|
||||
|
||||
print dol_get_fiche_head();
|
||||
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'" name="save" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="export" />';
|
||||
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 '<table width="100%" class="noborder">';
|
||||
|
||||
print '<tr class="liste_titre"><td colspan="2">';
|
||||
print 'Paramètres de l\'export';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>Période d\'analyse</td>';
|
||||
print '<td>';
|
||||
$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 '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
print '<input class="butAction" type="submit" value="Exporter XML" />';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
function _export_xml_deb($type_declaration, $period_year, $period_month) {
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
function _export_xml_des($type_declaration, $period_year, $period_month) {
|
||||
|
||||
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');
|
||||
}
|
||||
*/
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
|
|||
|
|
@ -482,8 +482,11 @@ class IntracommReport extends CommonObject
|
|||
*/
|
||||
public function generateXMLFile()
|
||||
{
|
||||
$name = $this->periode.'.xml';
|
||||
$name = $this->period.'.xml';
|
||||
|
||||
// TODO Must be stored into a dolibarr temp directory
|
||||
$fname = sys_get_temp_dir().'/'.$name;
|
||||
|
||||
$f = fopen($fname, 'w+');
|
||||
fwrite($f, $this->content_xml);
|
||||
fclose($f);
|
||||
|
|
@ -495,6 +498,7 @@ class IntracommReport extends CommonObject
|
|||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: '.filesize($fname));
|
||||
|
||||
readfile($fname);
|
||||
exit;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue