Merge branch 'develop' into prod-attr
# Conflicts: # htdocs/install/mysql/tables/llx_product_attribute.key.sql # htdocs/install/mysql/tables/llx_product_attribute_combination2val.sql
This commit is contained in:
commit
b1c552ee9d
@ -48,6 +48,8 @@ $langs->load('companies');
|
||||
$langs->load('compta');
|
||||
$langs->load('bills');
|
||||
|
||||
$action=GETPOST('action','alpha');
|
||||
$massaction=GETPOST('massaction','alpha');
|
||||
$orderyear=GETPOST("orderyear","int");
|
||||
$ordermonth=GETPOST("ordermonth","int");
|
||||
$orderday=GETPOST("orderday","int");
|
||||
@ -70,6 +72,7 @@ $search_sale=GETPOST('search_sale','int');
|
||||
$search_total_ht=GETPOST('search_total_ht','alpha');
|
||||
$optioncss = GETPOST('optioncss','alpha');
|
||||
$billed = GETPOST('billed','int');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
|
||||
// Security check
|
||||
$id = (GETPOST('orderid')?GETPOST('orderid','int'):GETPOST('id','int'));
|
||||
@ -183,6 +186,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
|
||||
$deliveryyear='';
|
||||
$viewstatut='';
|
||||
$billed='';
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
|
||||
@ -201,6 +205,148 @@ if (empty($reshook))
|
||||
$error++;
|
||||
}
|
||||
|
||||
// TODO Use a common inc.php file
|
||||
if (! $error && $massaction == 'delete' && $user->rights->commande->supprimer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$objecttmp=new Commande($db);
|
||||
$nbok = 0;
|
||||
foreach($toselect as $toselectid)
|
||||
{
|
||||
$result=$objecttmp->fetch($toselectid);
|
||||
if ($result > 0)
|
||||
{
|
||||
$result = $objecttmp->delete($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
else $nbok++;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
|
||||
else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
//var_dump($listofobjectthirdparties);exit;
|
||||
}
|
||||
|
||||
if (! $error && $massaction == "builddoc" && $user->rights->commande->lire && ! GETPOST('button_search'))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
$objecttmp=new Commande($db);
|
||||
$listofobjectid=array();
|
||||
$listofobjectthirdparties=array();
|
||||
$listofobjectref=array();
|
||||
foreach($toselect as $toselectid)
|
||||
{
|
||||
$objecttmp=new Commande($db); // must create new instance because instance is saved into $listofobjectref array for future use
|
||||
$result=$objecttmp->fetch($toselectid);
|
||||
if ($result > 0)
|
||||
{
|
||||
$listoinvoicesid[$toselectid]=$toselectid;
|
||||
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
|
||||
$listofobjectthirdparties[$thirdpartyid]=$thirdpartyid;
|
||||
$listofobjectref[$toselectid]=$objecttmp->ref;
|
||||
}
|
||||
}
|
||||
|
||||
$arrayofinclusion=array();
|
||||
foreach($listofobjectref as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/');
|
||||
$listoffiles = dol_dir_list($conf->commande->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true);
|
||||
|
||||
// build list of files with full path
|
||||
$files = array();
|
||||
foreach($listofobjectref as $basename)
|
||||
{
|
||||
foreach($listoffiles as $filefound)
|
||||
{
|
||||
if (strstr($filefound["name"],$basename))
|
||||
{
|
||||
$files[] = $conf->commande->dir_output.'/'.$basename.'/'.$filefound["name"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Define output language (Here it is not used because we do only merging existing PDF)
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id');
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
// Create empty PDF
|
||||
$pdf=pdf_getInstance();
|
||||
if (class_exists('TCPDF'))
|
||||
{
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($outputlangs));
|
||||
|
||||
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
|
||||
|
||||
// Add all others
|
||||
foreach($files as $file)
|
||||
{
|
||||
// Charge un document PDF depuis un fichier.
|
||||
$pagecount = $pdf->setSourceFile($file);
|
||||
for ($i = 1; $i <= $pagecount; $i++)
|
||||
{
|
||||
$tplidx = $pdf->importPage($i);
|
||||
$s = $pdf->getTemplatesize($tplidx);
|
||||
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
|
||||
$pdf->useTemplate($tplidx);
|
||||
}
|
||||
}
|
||||
|
||||
// Create output dir if not exists
|
||||
dol_mkdir($diroutputmassaction);
|
||||
|
||||
// Save merged file
|
||||
$filename=strtolower(dol_sanitizeFileName($langs->transnoentities("Orders")));
|
||||
if ($year) $filename.='_'.$year;
|
||||
if ($month) $filename.='_'.$month;
|
||||
if ($pagecount)
|
||||
{
|
||||
$now=dol_now();
|
||||
$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
|
||||
$pdf->Output($file,'F');
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$langs->load("exports");
|
||||
setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -380,6 +526,8 @@ if ($resql)
|
||||
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
$param='';
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
@ -408,8 +556,14 @@ if ($resql)
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
|
||||
|
||||
$arrayofmassactions = array(
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
);
|
||||
if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
@ -420,7 +574,7 @@ if ($resql)
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
@ -657,7 +811,7 @@ if ($resql)
|
||||
}
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="middle">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(0);
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
|
||||
@ -1001,7 +1155,14 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Action column
|
||||
print '<td></td>';
|
||||
print '<td class="nowrap" align="center">';
|
||||
if ($massactionbutton)
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
print '</tr>';
|
||||
|
||||
@ -205,12 +205,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS
|
||||
$day='';
|
||||
$year='';
|
||||
$month='';
|
||||
$toselect='';
|
||||
$option='';
|
||||
$filter='';
|
||||
$day_lim='';
|
||||
$year_lim='';
|
||||
$month_lim='';
|
||||
$toselect='';
|
||||
$search_array_options=array();
|
||||
}
|
||||
|
||||
@ -229,6 +229,7 @@ if (empty($reshook))
|
||||
$error++;
|
||||
}
|
||||
|
||||
// TODO Use a common inc.php file
|
||||
if (! $error && $massaction == 'confirm_presend')
|
||||
{
|
||||
$resaction = '';
|
||||
@ -522,17 +523,17 @@ if (empty($reshook))
|
||||
|
||||
$arrayofinclusion=array();
|
||||
foreach($listofobjectref as $tmppdf) $arrayofinclusion[]=preg_quote($tmppdf.'.pdf','/');
|
||||
$factures = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true);
|
||||
$listoffiles = dol_dir_list($conf->facture->dir_output,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true);
|
||||
|
||||
// liste les fichiers
|
||||
// build list of files with full path
|
||||
$files = array();
|
||||
foreach($listofobjectref as $basename)
|
||||
{
|
||||
foreach($factures as $facture)
|
||||
foreach($listoffiles as $filefound)
|
||||
{
|
||||
if (strstr($facture["name"],$basename))
|
||||
if (strstr($filefound["name"],$basename))
|
||||
{
|
||||
$files[] = $conf->facture->dir_output.'/'.$basename.'/'.$facture["name"];
|
||||
$files[] = $conf->facture->dir_output.'/'.$basename.'/'.$filefound["name"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -831,7 +832,12 @@ if ($resql)
|
||||
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
|
||||
}
|
||||
|
||||
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
|
||||
$arrayofmassactions=array(
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'builddoc'=>$langs->trans("PDFMerge")
|
||||
);
|
||||
if ($massaction == 'presend') $arrayofmassactions=array();
|
||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
$i = 0;
|
||||
print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
@ -843,7 +849,7 @@ if ($resql)
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">';
|
||||
|
||||
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,$massactionbutton,$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit);
|
||||
print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);
|
||||
|
||||
if ($massaction == 'presend')
|
||||
{
|
||||
@ -1183,7 +1189,7 @@ if ($resql)
|
||||
}
|
||||
// Action column
|
||||
print '<td class="liste_titre" align="middle">';
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1);
|
||||
$searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
|
||||
print $searchpitco;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
@ -1423,9 +1429,12 @@ if ($resql)
|
||||
|
||||
// Action column
|
||||
print '<td class="nowrap" align="center">';
|
||||
$selected=0;
|
||||
if (in_array($obj->facid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected?' checked="checked"':'').'>';
|
||||
if ($massactionbutton)
|
||||
{
|
||||
$selected=0;
|
||||
if (in_array($obj->facid, $arrayofselected)) $selected=1;
|
||||
print '<input id="cb'.$obj->facid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->facid.'"'.($selected?' checked="checked"':'').'>';
|
||||
}
|
||||
print '</td>' ;
|
||||
if (! $i) $totalarray['nbfield']++;
|
||||
|
||||
|
||||
@ -6014,7 +6014,7 @@ class Form
|
||||
/**
|
||||
* Return HTML to show the search and clear seach button
|
||||
*
|
||||
* @param int $addcheckuncheckall Add the check all uncheck all button
|
||||
* @param int $addcheckuncheckall Add the check all/uncheck all checkbox (use javascript) and code to manage this
|
||||
* @param string $cssclass CSS class
|
||||
* @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes
|
||||
* @return string
|
||||
@ -6029,8 +6029,7 @@ class Form
|
||||
if ($addcheckuncheckall)
|
||||
{
|
||||
if (! empty($conf->use_javascript_ajax)) $out.='<input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions">';
|
||||
}
|
||||
$out.='<script type="text/javascript">
|
||||
$out.='<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#checkallactions").click(function() {
|
||||
if($(this).is(\':checked\')){
|
||||
@ -6042,10 +6041,11 @@ class Form
|
||||
console.log("We uncheck all");
|
||||
$(".'.$cssclass.'").prop(\'checked\', false);
|
||||
}'."\n";
|
||||
if ($calljsfunction) $out.='if (typeof initCheckForSelect == \'function\') { initCheckForSelect(); } else { console.log("No function initCheckForSelect found. Call won\'t done."); }';
|
||||
$out.=' });
|
||||
});
|
||||
</script>';
|
||||
if ($calljsfunction) $out.='if (typeof initCheckForSelect == \'function\') { initCheckForSelect(); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
|
||||
$out.=' });
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
@ -606,10 +606,13 @@ class DoliDBMysql extends DoliDB
|
||||
$sql="SHOW TABLES FROM ".$database." ".$like.";";
|
||||
//print $sql;
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
}
|
||||
return $listtables;
|
||||
}
|
||||
|
||||
@ -627,10 +630,13 @@ class DoliDBMysql extends DoliDB
|
||||
|
||||
dol_syslog($sql,LOG_DEBUG);
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$infotables[] = $row;
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$infotables[] = $row;
|
||||
}
|
||||
}
|
||||
return $infotables;
|
||||
}
|
||||
|
||||
|
||||
@ -589,9 +589,12 @@ class DoliDBMysqli extends DoliDB
|
||||
$sql="SHOW TABLES FROM ".$database." ".$like.";";
|
||||
//print $sql;
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
if ($result)
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
}
|
||||
return $listtables;
|
||||
}
|
||||
@ -610,9 +613,12 @@ class DoliDBMysqli extends DoliDB
|
||||
|
||||
dol_syslog($sql,LOG_DEBUG);
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
if ($result)
|
||||
{
|
||||
$infotables[] = $row;
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$infotables[] = $row;
|
||||
}
|
||||
}
|
||||
return $infotables;
|
||||
}
|
||||
|
||||
@ -861,10 +861,13 @@ class DoliDBPgsql extends DoliDB
|
||||
$like = '';
|
||||
if ($table) $like = " AND table_name LIKE '".$table."'";
|
||||
$result = pg_query($this->db, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'".$like." ORDER BY table_name");
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
}
|
||||
return $listtables;
|
||||
}
|
||||
|
||||
|
||||
@ -747,9 +747,12 @@ class DoliDBSqlite extends DoliDB
|
||||
$sql="SHOW TABLES FROM ".$database." ".$like.";";
|
||||
//print $sql;
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
if ($result)
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
}
|
||||
return $listtables;
|
||||
}
|
||||
@ -769,9 +772,12 @@ class DoliDBSqlite extends DoliDB
|
||||
|
||||
dol_syslog($sql,LOG_DEBUG);
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
if ($result)
|
||||
{
|
||||
$infotables[] = $row;
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$infotables[] = $row;
|
||||
}
|
||||
}
|
||||
return $infotables;
|
||||
}
|
||||
|
||||
@ -831,9 +831,12 @@ class DoliDBSqlite3 extends DoliDB
|
||||
$sql="SHOW TABLES FROM ".$database." ".$like.";";
|
||||
//print $sql;
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
if ($result)
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$listtables[] = $row[0];
|
||||
}
|
||||
}
|
||||
return $listtables;
|
||||
}
|
||||
@ -853,9 +856,12 @@ class DoliDBSqlite3 extends DoliDB
|
||||
|
||||
dol_syslog($sql,LOG_DEBUG);
|
||||
$result = $this->query($sql);
|
||||
while($row = $this->fetch_row($result))
|
||||
if ($result)
|
||||
{
|
||||
$infotables[] = $row;
|
||||
while($row = $this->fetch_row($result))
|
||||
{
|
||||
$infotables[] = $row;
|
||||
}
|
||||
}
|
||||
return $infotables;
|
||||
}
|
||||
|
||||
@ -95,36 +95,41 @@ if ($action == 'create')
|
||||
// If no start date
|
||||
if (empty($date_debut))
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=nodatedebut');
|
||||
exit;
|
||||
setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
// If no end date
|
||||
if (empty($date_fin))
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=nodatefin');
|
||||
exit;
|
||||
setEventMessages($langs->trans("NoDateFin"), null, 'errors');
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
// If start date after end date
|
||||
if ($date_debut > $date_fin)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=datefin');
|
||||
exit;
|
||||
setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
|
||||
// Check if there is already holiday for this period
|
||||
$verifCP = $cp->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday);
|
||||
if (! $verifCP)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=alreadyCP');
|
||||
exit;
|
||||
setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
|
||||
// If there is no Business Days within request
|
||||
$nbopenedday=num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
|
||||
if($nbopenedday < 0.5)
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?action=request&error=DureeHoliday');
|
||||
exit;
|
||||
setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors');
|
||||
$error++;
|
||||
$action='create';
|
||||
}
|
||||
|
||||
// If no validator designated
|
||||
@ -823,10 +828,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
||||
print '<td>';
|
||||
// Si la demande ne vient pas de l'agenda
|
||||
if (! GETPOST('date_debut_')) {
|
||||
$form->select_date(-1,'date_debut_');
|
||||
$form->select_date(-1, 'date_debut_', 0, 0, 0, '', 1, 1);
|
||||
} else {
|
||||
$tmpdate = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
|
||||
$form->select_date($tmpdate,'date_debut_');
|
||||
$form->select_date($tmpdate, 'date_debut_', 0, 0, 0, '', 1, 1);
|
||||
}
|
||||
print ' ';
|
||||
print $form->selectarray('starthalfday', $listhalfday, (GETPOST('starthalfday')?GETPOST('starthalfday'):'morning'));
|
||||
@ -839,10 +844,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
||||
print '<td>';
|
||||
// Si la demande ne vient pas de l'agenda
|
||||
if (! GETPOST('date_fin_')) {
|
||||
$form->select_date(-1,'date_fin_');
|
||||
$form->select_date(-1,'date_fin_', 0, 0, 0, '', 1, 1);
|
||||
} else {
|
||||
$tmpdate = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
|
||||
$form->select_date($tmpdate,'date_fin_');
|
||||
$form->select_date($tmpdate,'date_fin_', 0, 0, 0, '', 1, 1);
|
||||
}
|
||||
print ' ';
|
||||
print $form->selectarray('endhalfday', $listhalfday, (GETPOST('endhalfday')?GETPOST('endhalfday'):'afternoon'));
|
||||
@ -861,7 +866,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("DescCP").'</td>';
|
||||
print '<td>';
|
||||
print '<textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70"></textarea>';
|
||||
print '<textarea name="description" class="flat" rows="'.ROWS_3.'" cols="70">'.GETPOST('description').'</textarea>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -1364,330 +1364,10 @@ class Holiday extends CommonObject
|
||||
{
|
||||
if (empty($userCP)) $userCP=0;
|
||||
dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP);
|
||||
/*
|
||||
// On vérifie les users Dolibarr sans CP
|
||||
if ($userDolibarrWithoutCP > 0)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
//$this->updateConfCP('nbUser',$userDolibarrWithoutCP);
|
||||
|
||||
$listUsersCP = $this->fetchUsers(true,false);
|
||||
|
||||
// On séléctionne les utilisateurs qui ne sont pas déjà dans le module
|
||||
$sql = "SELECT u.rowid, u.lastname, u.firstname";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
if ($listUsersCP != '') $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$uid = $obj->rowid;
|
||||
|
||||
// On ajoute l'utilisateur
|
||||
//print "Add user rowid = ".$uid." into database holiday";
|
||||
|
||||
$result = $this->createCPusers(true,$uid);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
} else {
|
||||
// Erreur SQL
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
// Si il y a moins d'utilisateur Dolibarr que dans le module CP
|
||||
|
||||
$this->updateConfCP('nbUser',$userDolibarrWithoutCP);
|
||||
|
||||
$listUsersDolibarr = $this->fetchUsers(true,true);
|
||||
|
||||
// On séléctionne les utilisateurs qui ne sont pas déjà dans le module
|
||||
$sql = "SELECT u.fk_user";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as u";
|
||||
$sql.= " WHERE u.fk_user NOT IN (".$listUsersDolibarr.")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql) {
|
||||
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while($i < $num) {
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// On supprime l'utilisateur
|
||||
$this->deleteCPuser($obj->fk_user);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
} else {
|
||||
// Erreur SQL
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Liste les évènements de congés payés enregistré
|
||||
*
|
||||
* @return int -1 si erreur, 1 si OK et 2 si pas de résultat
|
||||
*/
|
||||
function fetchEventsCP()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql.= " cpe.rowid,";
|
||||
$sql.= " cpe.name,";
|
||||
$sql.= " cpe.value";
|
||||
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_events as cpe";
|
||||
|
||||
dol_syslog(get_class($this)."::fetchEventsCP", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql) {
|
||||
|
||||
$i = 0;
|
||||
$tab_result = $this->events;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
// Si pas d'enregistrement
|
||||
if(!$num) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
// On liste les résultats et on les ajoutent dans le tableau
|
||||
while($i < $num) {
|
||||
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$tab_result[$i]['rowid'] = $obj->rowid;
|
||||
$tab_result[$i]['name'] = $obj->name;
|
||||
$tab_result[$i]['value'] = $obj->value;
|
||||
|
||||
$i++;
|
||||
}
|
||||
// Retourne 1 et ajoute le tableau à la variable
|
||||
$this->events = $tab_result;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Erreur SQL
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Créer un évènement de congés payés
|
||||
*
|
||||
* @param User $user User
|
||||
* @param int $notrigger No trigger
|
||||
* @return int -1 si erreur, id si OK
|
||||
*/
|
||||
function createEventCP($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_events (";
|
||||
|
||||
$sql.= "name,";
|
||||
$sql.= "value";
|
||||
|
||||
$sql.= ") VALUES (";
|
||||
|
||||
$sql.= " '".$this->db->escape($this->optName)."',";
|
||||
$sql.= " '".$this->optValue."'";
|
||||
$sql.= ")";
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::createEventCP", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) {
|
||||
$error++; $this->errors[]="Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_events");
|
||||
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::createEventCP ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->optRowid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Met à jour les évènements de congés payés
|
||||
*
|
||||
* @param int $rowid Row id
|
||||
* @param string $name Name
|
||||
* @param value $value Value
|
||||
* @return int -1 si erreur, id si OK
|
||||
*/
|
||||
function updateEventCP($rowid, $name, $value) {
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_events SET";
|
||||
$sql.= " name = '".$this->db->escape($name)."', value = '".$value."'";
|
||||
$sql.= " WHERE rowid = '".$rowid."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if($result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select event
|
||||
*
|
||||
* @return string|false Select Html to select type of holiday
|
||||
*/
|
||||
function selectEventCP()
|
||||
{
|
||||
|
||||
$sql = "SELECT rowid, name, value";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_events";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
$out = '<select name="list_event" class="flat" >';
|
||||
$out.= '<option value="-1"> </option>';
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$out.= '<option value="'.$obj->rowid.'">'.$obj->name.' ('.$obj->value.')</option>';
|
||||
$i++;
|
||||
}
|
||||
$out.= '</select>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* deleteEvent
|
||||
*
|
||||
* @param int $rowid Row id
|
||||
* @return boolean Success or not
|
||||
*/
|
||||
function deleteEventCP($rowid) {
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_events";
|
||||
$sql.= " WHERE rowid = '".$rowid."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if($result) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getValueEventCp
|
||||
*
|
||||
* @param int $rowid Row id
|
||||
* @return string|false
|
||||
*/
|
||||
function getValueEventCp($rowid) {
|
||||
|
||||
$sql = "SELECT value";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_events";
|
||||
$sql.= " WHERE rowid = '".$rowid."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if($result) {
|
||||
$obj = $this->db->fetch_array($result);
|
||||
return number_format($obj['value'],2);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getNameEventCp
|
||||
*
|
||||
* @param int $rowid Row id
|
||||
* @return unknown|boolean
|
||||
*/
|
||||
function getNameEventCp($rowid) {
|
||||
|
||||
$sql = "SELECT name";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_events";
|
||||
$sql.= " WHERE rowid = '".$rowid."'";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if($result) {
|
||||
$obj = $this->db->fetch_array($result);
|
||||
return $obj['name'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* addLogCP
|
||||
*
|
||||
|
||||
@ -106,46 +106,6 @@ if ($action == 'update' && isset($_POST['update_cp']))
|
||||
|
||||
if (! $error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
|
||||
}
|
||||
elseif($action == 'add_event')
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$typeleaves=$holiday->getTypes(1,1);
|
||||
|
||||
if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) {
|
||||
$event = $_POST['list_event'];
|
||||
} else { $error++;
|
||||
}
|
||||
|
||||
if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) {
|
||||
$userCP = $_POST['userCP'];
|
||||
} else { $erro++;
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
setEventMessages('ErrorAddEventToUserCP', '', 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$nb_holiday = $holiday->getCPforUser($userCP);
|
||||
$add_holiday = $holiday->getValueEventCp($event);
|
||||
$new_holiday = $nb_holiday + $add_holiday;
|
||||
|
||||
// add event to existing types of vacation
|
||||
foreach ($typeleaves as $key => $leave)
|
||||
{
|
||||
$vacationTypeID = $leave['rowid'];
|
||||
|
||||
// On ajoute la modification dans le LOG
|
||||
$holiday->addLogCP($user->id,$userCP, $holiday->getNameEventCp($event),$new_holiday, $vacationTypeID);
|
||||
|
||||
$holiday->updateSoldeCP($userCP,$new_holiday, $vacationTypeID);
|
||||
}
|
||||
|
||||
setEventMessages('AddEventToUserOkCP', '', 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@ -186,24 +146,6 @@ if (is_numeric($listUsers) && $listUsers < 0)
|
||||
$var=true;
|
||||
$i = 0;
|
||||
|
||||
$cp_events = $holiday->fetchEventsCP();
|
||||
if ($cp_events == 1)
|
||||
{
|
||||
print '<br><form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
print '<input type="hidden" name="action" value="add_event" />';
|
||||
|
||||
print load_fiche_titre($langs->trans('DefineEventUserCP'),'','');
|
||||
|
||||
print $langs->trans('MotifCP').' : ';
|
||||
print $holiday->selectEventCP();
|
||||
print ' '.$langs->trans('UserCP').' : ';
|
||||
print $form->select_dolusers('', 'userCP', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
|
||||
print ' <input type="submit" value="'.$langs->trans("addEventToUserCP").'" name="bouton" class="button"/>';
|
||||
|
||||
print '</form><br>';
|
||||
}
|
||||
|
||||
|
||||
$typeleaves=$holiday->getTypes(1,1);
|
||||
|
||||
if (count($typeleaves) == 0)
|
||||
|
||||
@ -66,6 +66,21 @@ $year_end = GETPOST('year_end');
|
||||
$search_employe = GETPOST('search_employe');
|
||||
$search_valideur = GETPOST('search_valideur');
|
||||
$search_statut = GETPOST('select_statut');
|
||||
$type = GETPOST('type','int');
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array(
|
||||
'cp.rowid'=>'Ref',
|
||||
'cp.description'=>'Description',
|
||||
'uu.lastname'=>'EmployeeLastname',
|
||||
'uu.firstname'=>'EmployeeFirstname'
|
||||
);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
|
||||
{
|
||||
@ -79,23 +94,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
|
||||
$search_employe="";
|
||||
$search_valideur="";
|
||||
$search_statut="";
|
||||
$type='';
|
||||
}
|
||||
|
||||
// List of fields to search into when doing a "search in all"
|
||||
$fieldstosearchall = array(
|
||||
'cp.rowid'=>'Ref',
|
||||
'cp.description'=>'Description',
|
||||
'uu.lastname'=>'EmployeeLastname',
|
||||
'uu.firstname'=>'EmployeeFirstname'
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// None
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -193,6 +194,8 @@ if (!empty($sall))
|
||||
|
||||
if (empty($user->rights->holiday->read_all)) $filter.=' AND cp.fk_user IN ('.join(',',$childids).')';
|
||||
|
||||
if ($type) $filter.=' AND cp.fk_type IN ('.$type.')';
|
||||
|
||||
// Récupération de l'ID de l'utilisateur
|
||||
$user_id = $user->id;
|
||||
|
||||
@ -302,12 +305,12 @@ print "</tr>\n";
|
||||
|
||||
// FILTRES
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" align="left" width="50">';
|
||||
print '<td class="liste_titre" align="left">';
|
||||
print '<input class="flat" size="4" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
print '</td>';
|
||||
|
||||
// DATE CREATE
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month_create" value="'.$month_create.'">';
|
||||
$formother->select_year($year_create,'year_create',1, $min_year, 0);
|
||||
print '</td>';
|
||||
@ -346,20 +349,29 @@ else
|
||||
}
|
||||
|
||||
// Type
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<td class="liste_titre">';
|
||||
$typeleaves=$holidaystatic->getTypes(1,-1);
|
||||
$arraytypeleaves=array();
|
||||
foreach($typeleaves as $key => $val)
|
||||
{
|
||||
$labeltoshow = $val['label'];
|
||||
//$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
|
||||
$arraytypeleaves[$val['rowid']]=$labeltoshow;
|
||||
}
|
||||
print $form->selectarray('type', $arraytypeleaves, (GETPOST('type')?GETPOST('type'):''), 1);
|
||||
print '</td>';
|
||||
|
||||
// DUREE
|
||||
print '<td> </td>';
|
||||
|
||||
// DATE DEBUT
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month_start" value="'.$month_start.'">';
|
||||
$formother->select_year($year_start,'year_start',1, $min_year, $max_year);
|
||||
print '</td>';
|
||||
|
||||
// DATE FIN
|
||||
print '<td class="liste_titre" colspan="1" align="center">';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month_end" value="'.$month_end.'">';
|
||||
$formother->select_year($year_end,'year_end',1, $min_year, $max_year);
|
||||
print '</td>';
|
||||
|
||||
@ -36,6 +36,8 @@ ALTER TABLE llx_ecm_files ADD COLUMN gen_or_uploaded varchar(12) after cover;
|
||||
|
||||
DROP TABLE llx_document_generator;
|
||||
DROP TABLE llx_ecm_documents;
|
||||
DROP TABLE llx_holiday_events;
|
||||
DROP TABLE llx_holiday_types;
|
||||
|
||||
ALTER TABLE llx_notify ADD COLUMN type_target varchar(16) NULL;
|
||||
|
||||
|
||||
@ -567,6 +567,7 @@ CanBeModifiedIfOk=Can be modified if valid
|
||||
CanBeModifiedIfKo=Can be modified if not valid
|
||||
RecordModifiedSuccessfully=Record modified successfully
|
||||
RecordsModified=%s records modified
|
||||
RecordsDeleted=%s records deleted
|
||||
AutomaticCode=Automatic code
|
||||
FeatureDisabled=Feature disabled
|
||||
MoveBox=Move widget
|
||||
|
||||
Loading…
Reference in New Issue
Block a user