Clean code

This commit is contained in:
Laurent Destailleur 2017-09-05 10:16:08 +02:00
parent a0cdf784da
commit f23a681dc0
13 changed files with 46 additions and 51 deletions

View File

@ -232,14 +232,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$i=0; $i=0;
foreach ($listfieldinsert as $f => $value) foreach ($listfieldinsert as $f => $value)
{ {
if ($value == 'price' || preg_match('/^amount/i',$value) || $value == 'taux') { if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
}
else if ($value == 'entity') {
$_POST[$listfieldvalue[$i]] = $conf->entity; $_POST[$listfieldvalue[$i]] = $conf->entity;
} }
if ($i) $sql.=","; if ($i) $sql.=",";
if ($_POST[$listfieldvalue[$i]] == '' && ! ($listfieldvalue[$i] == 'code' && $id == 10)) $sql.="null"; // For vat, we want/accept code = '' if ($_POST[$listfieldvalue[$i]] == '' && ! $listfieldvalue[$i] == 'formula') $sql.="null"; // For vat, we want/accept code = ''
else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'"; else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
$i++; $i++;
} }

View File

@ -85,7 +85,6 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
} }
$name=$langs->trans("PurchasesJournal"); $name=$langs->trans("PurchasesJournal");
$namelink='';
$periodlink=''; $periodlink='';
$exportlink=''; $exportlink='';
$builddate=dol_now(); $builddate=dol_now();
@ -94,7 +93,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $
else $description.= $langs->trans("DepositsAreIncluded"); else $description.= $langs->trans("DepositsAreIncluded");
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink);
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0]; $idpays = $p[0];

View File

@ -89,7 +89,6 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end
} }
$nom=$langs->trans("SellsJournal"); $nom=$langs->trans("SellsJournal");
$namelink='';
$periodlink=''; $periodlink='';
$exportlink=''; $exportlink='';
$builddate=dol_now(); $builddate=dol_now();
@ -97,7 +96,7 @@ $description=$langs->trans("DescSellsJournal").'<br>';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded"); else $description.= $langs->trans("DepositsAreIncluded");
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink);
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
$idpays = $p[0]; $idpays = $p[0];

View File

@ -142,7 +142,7 @@ if ($calc==2) // Invoice for goods, payment for services
$productsup=$langs->trans("Description"); $productsup=$langs->trans("Description");
$amountsup=$langs->trans("AmountHT"); $amountsup=$langs->trans("AmountHT");
} }
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
$vatcust=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code); $vatcust=$langs->transcountry($local==1?"LT1":"LT2",$mysoc->country_code);

View File

@ -177,7 +177,7 @@ if ($conf->global->$calc==2) // Invoice for goods, payment for services
$vatsup=$langs->trans("VATPaid"); $vatsup=$langs->trans("VATPaid");
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
} }
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
if($local==1){ if($local==1){

View File

@ -147,7 +147,6 @@ llxHeader();
$form=new Form($db); $form=new Form($db);
$namelink='';
$periodlink=''; $periodlink='';
$exportlink=''; $exportlink='';
@ -200,7 +199,7 @@ elseif ($modecompta=="BOOKKEEPING")
$hselected = 'report'; $hselected = 'report';
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode);
if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{ {

View File

@ -113,7 +113,6 @@ llxHeader();
$form=new Form($db); $form=new Form($db);
$namelink='';
$exportlink=''; $exportlink='';
// Affiche en-tete du rapport // Affiche en-tete du rapport
@ -160,7 +159,7 @@ else if ($modecompta=="BOOKKEEPING")
$hselected='report'; $hselected='report';
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array('modecompta'=>$modecompta),$calcmode);
if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{ {

View File

@ -194,7 +194,6 @@ else if ($modecompta=="BOOKKEEPING")
$calcmode=$langs->trans("CalcModeBookkeeping"); $calcmode=$langs->trans("CalcModeBookkeeping");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')'; //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')'; //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$nomlink = '';
$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
$period.=' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0); $period.=' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '. $form->selectyesno('showaccountdetail',$showaccountdetail,0);
$periodlink = $textprevyear . " " . $langs->trans("Year") . " " . $start_year . " " . $textnextyear ; $periodlink = $textprevyear . " " . $langs->trans("Year") . " " . $start_year . " " . $textnextyear ;
@ -206,7 +205,7 @@ else if ($modecompta=="BOOKKEEPING")
$builddate=dol_now(); $builddate=dol_now();
} }
report_header($name, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'action' => ''), $calcmode); report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'action' => ''), $calcmode);
if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
@ -259,10 +258,10 @@ else if ($modecompta=="BOOKKEEPING")
$formula = $cat['formula']; $formula = $cat['formula'];
print "<tr>"; print '<tr class="liste_total">';
// Year NP // Year NP
print '<td class="width200">'; print '<td class="liste_total width200">';
print $cat['code']; print $cat['code'];
print '</td><td>'; print '</td><td>';
print $cat['label']; print $cat['label'];
@ -283,7 +282,7 @@ else if ($modecompta=="BOOKKEEPING")
$r = dol_eval($result, 1); $r = dol_eval($result, 1);
//var_dump($r); //var_dump($r);
print '<td align="right"><font color="blue">' . price($r) . '</font></td>'; print '<td class="liste_total right">' . price($r) . '</td>';
// Year N // Year N
$code = $cat['code']; // code of categorie ('VTE', 'MAR', ...) $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...)
@ -301,7 +300,7 @@ else if ($modecompta=="BOOKKEEPING")
//$r = $AccCat->calculate($result); //$r = $AccCat->calculate($result);
$r = dol_eval($result, 1); $r = dol_eval($result, 1);
print '<td align="right"><font color="blue">' . price($r) . '</font></td>'; print '<td class="liste_total right">' . price($r) . '</td>';
$sommes[$code]['N'] += $r; $sommes[$code]['N'] += $r;
// Detail by month // Detail by month
@ -315,7 +314,7 @@ else if ($modecompta=="BOOKKEEPING")
//$r = $AccCat->calculate($result); //$r = $AccCat->calculate($result);
$r = dol_eval($result, 1); $r = dol_eval($result, 1);
print '<td align="right"><font color="blue">' . price($r) . '</font></td>'; print '<td class="liste_total right">' . price($r) . '</td>';
$sommes[$code]['M'][$k] += $r; $sommes[$code]['M'][$k] += $r;
} }

View File

@ -220,7 +220,7 @@ if ($modetax==0) { // Invoice for goods, payment for services
$vatsup.=' ('.$langs->trans("ToGetBack").')'; $vatsup.=' ('.$langs->trans("ToGetBack").')';
} }
} }
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
$vatcust=$langs->trans("VATReceived"); $vatcust=$langs->trans("VATReceived");
$vatsup=$langs->trans("VATPaid"); $vatsup=$langs->trans("VATPaid");

View File

@ -210,7 +210,7 @@ if ($modetax==0) // Invoice for goods, payment for services
if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')';
} }
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
$vatcust=$langs->trans("VATReceived"); $vatcust=$langs->trans("VATReceived");
$vatsup=$langs->trans("VATPaid"); $vatsup=$langs->trans("VATPaid");

View File

@ -244,7 +244,7 @@ if ($modetax==0) { // Invoice for goods, payment for services
$vatsup.=' ('.$langs->trans("ToGetBack").')'; $vatsup.=' ('.$langs->trans("ToGetBack").')';
} }
} }
report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode);
$vatcust=$langs->trans("VATReceived"); $vatcust=$langs->trans("VATReceived");
$vatsup=$langs->trans("VATPaid"); $vatsup=$langs->trans("VATPaid");

View File

@ -24,10 +24,10 @@
/** /**
* Show header of a VAT report * Show header of a report
* *
* @param string $nom Name of report * @param string $reportname Name of report
* @param string $variante Link for alternate report * @param string $notused Not used
* @param string $period Period of report * @param string $period Period of report
* @param string $periodlink Link to switch period * @param string $periodlink Link to switch period
* @param string $description Description * @param string $description Description
@ -38,13 +38,13 @@
* @param string $varlink Add a variable into the address of the page * @param string $varlink Add a variable into the address of the page
* @return void * @return void
*/ */
function report_header($nom,$variante,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='') function report_header($reportname,$notused,$period,$periodlink,$description,$builddate,$exportlink='',$moreparam=array(),$calcmode='', $varlink='')
{ {
global $langs; global $langs;
if (empty($hselected)) $hselected='report'; if (empty($hselected)) $hselected='report';
print "\n\n<!-- debut cartouche rapport -->\n"; print "\n\n<!-- start banner of report -->\n";
if(! empty($varlink)) $varlink = '?'.$varlink; if(! empty($varlink)) $varlink = '?'.$varlink;
@ -53,23 +53,25 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
$head[$h][1] = $langs->trans("Report"); $head[$h][1] = $langs->trans("Report");
$head[$h][2] = 'report'; $head[$h][2] = 'report';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
dol_fiche_head($head, 'report'); dol_fiche_head($head, 'report');
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].$varlink.'">';
foreach($moreparam as $key => $value) foreach($moreparam as $key => $value)
{ {
print '<input type="hidden" name="'.$key.'" value="'.$value.'">'; print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
} }
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
$variante = ($periodlink || $exportlink);
// Ligne de titre // Ligne de titre
print '<tr>'; print '<tr>';
print '<td width="110">'.$langs->trans("ReportName").'</td>'; print '<td width="110">'.$langs->trans("ReportName").'</td>';
if (! $variantexxx) print '<td colspan="3">'; print '<td>';
else print '<td>'; print $reportname;
print $nom;
if ($variantexxx) print '</td><td colspan="2">'.$variantexxx;
print '</td>'; print '</td>';
if ($variante) print '<td></td>';
print '</tr>'; print '</tr>';
// Calculation mode // Calculation mode
@ -77,10 +79,9 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
{ {
print '<tr>'; print '<tr>';
print '<td width="110">'.$langs->trans("CalculationMode").'</td>'; print '<td width="110">'.$langs->trans("CalculationMode").'</td>';
if (! $variante) print '<td colspan="3">'; print '<td>';
else print '<td>';
print $calcmode; print $calcmode;
if ($variante) print '</td><td colspan="2">'.$variante; if ($variante) print '<td></td>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
@ -88,35 +89,37 @@ function report_header($nom,$variante,$period,$periodlink,$description,$builddat
// Ligne de la periode d'analyse du rapport // Ligne de la periode d'analyse du rapport
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("ReportPeriod").'</td>'; print '<td>'.$langs->trans("ReportPeriod").'</td>';
if (! $periodlink) print '<td colspan="3">'; print '<td>';
else print '<td>';
if ($period) print $period; if ($period) print $period;
if ($periodlink) print '</td><td colspan="2">'.$periodlink; if ($variante) print '<td>'.$periodlink.'</td>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Ligne de description // Ligne de description
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("ReportDescription").'</td>'; print '<td>'.$langs->trans("ReportDescription").'</td>';
print '<td colspan="3">'.$description.'</td>'; print '<td>'.$description.'</td>';
if ($variante) print '<td></td>';
print '</tr>'; print '</tr>';
// Ligne d'export // Ligne d'export
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("GeneratedOn").'</td>'; print '<td>'.$langs->trans("GeneratedOn").'</td>';
if (! $exportlink) print '<td colspan="3">'; print '<td>';
else print '<td>';
print dol_print_date($builddate, 'dayhour'); print dol_print_date($builddate, 'dayhour');
if ($exportlink) print '</td><td>'.$langs->trans("Export").'</td><td>'.$exportlink; print '</td>';
print '</td></tr>'; if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>';
print '</tr>';
print '</table>'; print '</table>';
print '<br><div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
print '</form>';
dol_fiche_end(); dol_fiche_end();
print "\n<!-- fin cartouche rapport -->\n\n"; print '<div class="center"><input type="submit" class="button" name="submit" value="'.$langs->trans("Refresh").'"></div>';
print '</form>';
print '<br>';
print "\n<!-- end banner of report -->\n\n";
} }

View File

@ -31,7 +31,7 @@ ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account
JournalizationInLedgerStatus=Status of journalization JournalizationInLedgerStatus=Status of journalization
AlreadyInGeneralLedger=Already journalized in ledgers AlreadyInGeneralLedger=Already journalized in ledgers
NotYetInGeneralLedger=Not yet journalized in ledgers NotYetInGeneralLedger=Not yet journalized in ledgers
GroupIsEmptyCheckSetup=Group is empty, check setup of the accounting group GroupIsEmptyCheckSetup=Group is empty, check setup of the personalized accounting group
DetailByAccount=Show detail by account DetailByAccount=Show detail by account
MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup