NEW Bulk actions available on supplier orders

This commit is contained in:
Laurent Destailleur 2017-04-09 13:12:25 +02:00
parent bb7c164752
commit 52c86cb3f5
12 changed files with 913 additions and 446 deletions

View File

@ -460,7 +460,7 @@ if ($id > 0)
} }
else else
{ {
print $langs->trans("ThirdpartyNotLinkedToMember"); print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -119,7 +119,6 @@ if ($socid > 0)
// Discount // Discount
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>"; print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -130,11 +129,11 @@ if ($socid > 0)
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// New value // New value
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield fieldrequired">';
print $langs->trans("NewValue").'</td><td><input type="text" size="5" name="remise" value="'.dol_escape_htmltag(GETPOST("remise")).'">%</td></tr>'; print $langs->trans("NewValue").'</td><td><input type="text" size="5" name="remise" value="'.dol_escape_htmltag(GETPOST("remise")).'">%</td></tr>';
// Motif/Note // Motif/Note
print '<tr><td>'; print '<tr><td class="fieldrequired">';
print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note")).'"></td></tr>'; print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note")).'"></td></tr>';
print "</table>"; print "</table>";
@ -179,14 +178,14 @@ if ($socid > 0)
print '<td align="left">'.$langs->trans("NoteReason").'</td>'; print '<td align="left">'.$langs->trans("NoteReason").'</td>';
print '<td align="center">'.$langs->trans("User").'</td>'; print '<td align="center">'.$langs->trans("User").'</td>';
print '</tr>'; print '</tr>';
$i = 0 ;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0)
{
$i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$tag = !$tag; print '<tr class="oddeven">';
print '<tr '.$bc[$tag].'>';
print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>'; print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
print '<td align="center">'.price2num($obj->remise_percent).'%</td>'; print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
print '<td align="left">'.$obj->note.'</td>'; print '<td align="left">'.$obj->note.'</td>';
@ -194,6 +193,11 @@ if ($socid > 0)
print '</tr>'; print '</tr>';
$i++; $i++;
} }
}
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$db->free($resql); $db->free($resql);
print "</table>"; print "</table>";
} }

View File

@ -274,6 +274,8 @@ if ($socid > 0)
} }
print '</table>'; print '</table>';
print '</div>';
if ($user->rights->societe->creer) if ($user->rights->societe->creer)
{ {
print '<br>'; print '<br>';
@ -294,7 +296,6 @@ if ($socid > 0)
print "</table>"; print "</table>";
} }
print '</div>';
dol_fiche_end(); dol_fiche_end();
@ -342,8 +343,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountStillRemaining")); print load_fiche_titre($langs->trans("DiscountStillRemaining"));
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="120" align="left">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM print '<td class="widthdate">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
print '<td align="left">'.$langs->trans("ReasonDiscount").'</td>'; print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>'; print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>'; print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>'; print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
@ -354,14 +355,15 @@ if ($socid > 0)
$showconfirminfo=array(); $showconfirminfo=array();
$var = true;
$i = 0; $i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0)
{
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var = !$var;
print "<tr ".$bc[$var].">"; print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>'; print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{ {
@ -406,7 +408,7 @@ if ($socid > 0)
if ($user->rights->societe->creer || $user->rights->facture->creer) if ($user->rights->societe->creer || $user->rights->facture->creer)
{ {
print '<td class="nowrap">'; print '<td class="nowrap">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=split&amp;remid='.$obj->rowid.'">'.img_picto($langs->trans("SplitDiscount"),'split').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=split&amp;remid='.$obj->rowid.'">'.img_split($langs->trans("SplitDiscount")).'</a>';
print ' &nbsp; '; print ' &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>'; print '</td>';
@ -421,6 +423,11 @@ if ($socid > 0)
} }
$i++; $i++;
} }
}
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$db->free($resql); $db->free($resql);
print "</table>"; print "</table>";
@ -491,8 +498,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountAlreadyCounted")); print load_fiche_titre($langs->trans("DiscountAlreadyCounted"));
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td width="120" align="left">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM print '<td class="widthdate">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
print '<td align="left">'.$langs->trans("ReasonDiscount").'</td>'; print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>'; print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>'; print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>'; print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
@ -501,16 +508,18 @@ if ($socid > 0)
print '<td width="50">&nbsp;</td>'; print '<td width="50">&nbsp;</td>';
print '</tr>'; print '</tr>';
$var = true;
$tab_sqlobj=array(); $tab_sqlobj=array();
$tab_sqlobjOrder=array(); $tab_sqlobjOrder=array();
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
if ($num > 0)
{
for ($i = 0;$i < $num; $i++) for ($i = 0;$i < $num; $i++)
{ {
$sqlobj = $db->fetch_object($resql); $sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]=$db->jdate($sqlobj->dc); $tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
} }
}
$db->free($resql); $db->free($resql);
$num = $db->num_rows($resql2); $num = $db->num_rows($resql2);
@ -524,12 +533,13 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj); array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj);
$num = count($tab_sqlobj); $num = count($tab_sqlobj);
if ($num > 0)
{
$i = 0 ; $i = 0 ;
while ($i < $num ) while ($i < $num )
{ {
$obj = array_shift($tab_sqlobj); $obj = array_shift($tab_sqlobj);
$var = !$var; print '<tr class="oddeven">';
print "<tr ".$bc[$var].">";
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>'; print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description)) if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{ {
@ -575,6 +585,12 @@ if ($socid > 0)
print '</tr>'; print '</tr>';
$i++; $i++;
} }
}
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table>"; print "</table>";
} }
else else

View File

@ -199,9 +199,8 @@ if (empty($reshook))
$permtodelete = $user->rights->commande->supprimer; $permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output; $uploaddir = $conf->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
// TODO Move this into mass action include
if ($massaction == 'confirm_createbills') { if ($massaction == 'confirm_createbills') {
$orders = GETPOST('toselect'); $orders = GETPOST('toselect');
@ -419,7 +418,7 @@ if ($massaction == 'confirm_createbills') {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
}
} }
@ -435,8 +434,9 @@ $formfile = new FormFile($db);
$companystatic = new Societe($db); $companystatic = new Societe($db);
$formcompany=new FormCompany($db); $formcompany=new FormCompany($db);
$title=$langs->trans("Orders");
$help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; $help_url="EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
llxHeader('',$langs->trans("Orders"),$help_url); llxHeader('',$title,$help_url);
$sql = 'SELECT'; $sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
@ -622,7 +622,6 @@ if ($resql)
if ($show_files) $param.='&show_files=' .$show_files; if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($billed != '') $param.='&billed='.$billed; if ($billed != '') $param.='&billed='.$billed;
// Add $param from extra fields // Add $param from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
{ {
@ -654,6 +653,7 @@ if ($resql)
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $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);
// TODO Move this into an invluce
if ($massaction == 'presend') if ($massaction == 'presend')
{ {
$langs->load("mails"); $langs->load("mails");
@ -679,9 +679,6 @@ if ($resql)
print '<input type="hidden" name="massaction" value="confirm_presend">'; print '<input type="hidden" name="massaction" value="confirm_presend">';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
dol_fiche_head(null, '', ''); dol_fiche_head(null, '', '');
$topicmail="SendOrderRef"; $topicmail="SendOrderRef";
@ -1428,8 +1425,6 @@ if ($resql)
print '</form>'."\n"; print '</form>'."\n";
//print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>';
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{ {
/* /*

View File

@ -6218,7 +6218,7 @@ class Form
global $conf, $langs; global $conf, $langs;
$out=''; $out='';
if (! empty($conf->use_javascript_ajax)) $out.='<input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions">'; if (! empty($conf->use_javascript_ajax)) $out.='<div class="inline-block checkallactions"><input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions"></div>';
$out.='<script type="text/javascript"> $out.='<script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("#checkallactions").click(function() { $("#checkallactions").click(function() {

View File

@ -312,7 +312,7 @@ class FormFile
if (preg_match('/massfilesarea_/', $modulepart)) if (preg_match('/massfilesarea_/', $modulepart))
{ {
$out.='<br><a name="show_files"></a>'; $out.='<div id="show_files"><br></div>';
$title=$langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>'; $title=$langs->trans("MassFilesArea").' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans("Hide").')</a>';
$title.='<script type="text/javascript" language="javascript"> $title.='<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
@ -461,7 +461,7 @@ class FormFile
$modellist=ModeleExports::liste_modeles($this->db); $modellist=ModeleExports::liste_modeles($this->db);
} }
} }
else if ($modulepart == 'commande_fournisseur') else if ($modulepart == 'commande_fournisseur' || $modulepart == 'supplier_order')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
@ -470,7 +470,7 @@ class FormFile
$modellist=ModelePDFSuppliersOrders::liste_modeles($this->db); $modellist=ModelePDFSuppliersOrders::liste_modeles($this->db);
} }
} }
else if ($modulepart == 'facture_fournisseur') else if ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice')
{ {
if (is_array($genallowed)) $modellist=$genallowed; if (is_array($genallowed)) $modellist=$genallowed;
else else
@ -688,7 +688,7 @@ class FormFile
{ {
$headershown=1; $headershown=1;
$out.= '<div class="titre">'.$titletoshow.'</div>'."\n"; $out.= '<div class="titre">'.$titletoshow.'</div>'."\n";
$out.= '<table class="border" summary="listofdocumentstable" id="'.$modulepart.'_table" width="100%">'."\n"; $out.= '<table class="noborder" summary="listofdocumentstable" id="'.$modulepart.'_table" width="100%">'."\n";
} }
// Loop on each file found // Loop on each file found

View File

@ -1815,6 +1815,30 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
} }
$original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; $original_file=$conf->expensereport->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
} }
else if ($modulepart == 'massfilesarea_supplier_proposal' && !empty($conf->propal->dir_output))
{
if ($fuser->rights->supplier_proposal->lire || preg_match('/^specimen/i',$original_file))
{
$accessallowed=1;
}
$original_file=$conf->propal->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
else if ($modulepart == 'massfilesarea_supplier_order')
{
if ($fuser->rights->fournisseur->commande->lire || preg_match('/^specimen/i',$original_file))
{
$accessallowed=1;
}
$original_file=$conf->fournisseur->commande->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
else if ($modulepart == 'massfilesarea_supplier_invoice')
{
if ($fuser->rights->fournisseur->facture->lire || preg_match('/^specimen/i',$original_file))
{
$accessallowed=1;
}
$original_file=$conf->fournisseur->facture->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file;
}
// Wrapping for interventions // Wrapping for interventions
else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output)) else if (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output))

View File

@ -2649,6 +2649,22 @@ function img_printer($titlealt = "default", $other='')
return img_picto($titlealt,'printer.png',$other); return img_picto($titlealt,'printer.png',$other);
} }
/**
* Show delete logo
*
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param string $other Add more attributes on img
* @return string Retourne tag img
*/
function img_split($titlealt = 'default', $other = 'class="pictosplit"')
{
global $conf, $langs;
if ($titlealt == 'default') $titlealt = $langs->trans('Split');
return img_picto($titlealt, 'split.png', $other);
}
/** /**
* Show help logo with cursor "?" * Show help logo with cursor "?"
* *

View File

@ -48,6 +48,12 @@ $langs->load('compta');
$langs->load('bills'); $langs->load('bills');
$langs->load('projects'); $langs->load('projects');
$action=GETPOST('action','alpha');
$massaction=GETPOST('massaction','alpha');
$show_files=GETPOST('show_files','int');
$confirm=GETPOST('confirm','alpha');
$toselect = GETPOST('toselect', 'array');
$orderyear=GETPOST("orderyear","int"); $orderyear=GETPOST("orderyear","int");
$ordermonth=GETPOST("ordermonth","int"); $ordermonth=GETPOST("ordermonth","int");
$orderday=GETPOST("orderday","int"); $orderday=GETPOST("orderday","int");
@ -92,7 +98,7 @@ $orderid = GETPOST('orderid','int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande'); $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id; $diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
@ -172,10 +178,13 @@ $parameters=array('socid'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{ {
$ordermonth=''; $ordermonth='';
$orderyear=''; $orderyear='';
@ -205,28 +214,247 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$deliverymonth=''; $deliverymonth='';
$deliveryyear=''; $deliveryyear='';
$billed=''; $billed='';
$toselect='';
$search_project_ref=''; $search_project_ref='';
$search_array_options=array(); $search_array_options=array();
// Mass actions
$objectclass='Commande';
$objectlabel='Orders';
$permtoread = $user->rights->commande->lire;
$permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
} }
if (empty($reshook)) // Mass actions
$objectclass='CommandeFournisseur';
$objectlabel='SupplierOrders';
$permtoread = $user->rights->fournisseur->commande->lire;
$permtodelete = $user->rights->fournisseur->commande->supprimer;
$uploaddir = $conf->fournisseur->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// TODO Move this into mass action include
if ($massaction == 'confirm_createbills')
{ {
// Mass actions. Controls on number of lines checked $orders = GETPOST('toselect');
$maxformassaction=1000; $createbills_onebythird = GETPOST('createbills_onebythird', 'int');
if (! empty($massaction) && count($toselect) < 1) $validate_invoices = GETPOST('valdate_invoices', 'int');
$TFact = array();
$TFactThird = array();
$nb_bills_created = 0;
$db->begin();
foreach($orders as $id_order) {
$cmd = new Commande($db);
if($cmd->fetch($id_order) <= 0) continue;
$object = new Facture($db);
if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
else {
$object->socid = $cmd->socid;
$object->type = Facture::TYPE_STANDARD;
$object->cond_reglement_id = $cmd->cond_reglement_id;
$object->mode_reglement_id = $cmd->mode_reglement_id;
$object->fk_project = $cmd->fk_project;
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture))
{ {
$error++; $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
} }
if (! $error && count($toselect) > $maxformassaction)
$object->date = $datefacture;
$object->origin = 'commande';
$object->origin_id = $id_order;
$res = $object->create($user);
if($res > 0) $nb_bills_created++;
}
if($object->id > 0) {
$db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
$sql.= "fk_source";
$sql.= ", sourcetype";
$sql.= ", fk_target";
$sql.= ", targettype";
$sql.= ") VALUES (";
$sql.= $id_order;
$sql.= ", '".$object->origin."'";
$sql.= ", ".$object->id;
$sql.= ", '".$object->element."'";
$sql.= ")";
if ($db->query($sql))
{ {
setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); $db->commit();
}
else
{
$db->rollback();
}
$lines = $cmd->lines;
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
{
$cmd->fetch_lines();
$lines = $cmd->lines;
}
$fk_parent_line=0;
$num=count($lines);
for ($i=0;$i<$num;$i++)
{
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
if ($lines[$i]->subprice < 0)
{
// Negative line, we create a discount line
$discount = new DiscountAbsolute($db);
$discount->fk_soc=$object->socid;
$discount->amount_ht=abs($lines[$i]->total_ht);
$discount->amount_tva=abs($lines[$i]->total_tva);
$discount->amount_ttc=abs($lines[$i]->total_ttc);
$discount->tva_tx=$lines[$i]->tva_tx;
$discount->fk_user=$user->id;
$discount->description=$desc;
$discountid=$discount->create($user);
if ($discountid > 0)
{
$result=$object->insert_discount($discountid);
//$result=$discount->link_to_invoice($lineid,$id);
}
else
{
setEventMessages($discount->error, $discount->errors, 'errors');
$error++;
break;
}
}
else
{
// Positive line
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
// Date start
$date_start=false;
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
//Date end
$date_end=false;
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
{
$fk_parent_line = 0;
}
$result = $object->addline(
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$date_start,
$date_end,
0,
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$product_type,
$ii,
$lines[$i]->special_code,
$object->origin,
$lines[$i]->rowid,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$lines[$i]->label
);
if ($result > 0)
{
$lineid=$result;
}
else
{
$lineid=0;
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9)
{
$fk_parent_line = $result;
}
}
}
}
$cmd->classifyBilled($user);
if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object;
else $TFact[$object->id] = $object;
}
// Build doc with all invoices
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
$toselect = array();
if(!empty($validate_invoices)) {
$massaction = $action = 'builddoc';
foreach($TAllFact as &$object) {
$object->validate($user);
$toselect[] = $object->id; // For builddoc action
// Fac builddoc
$upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
}
$objectclass='Facture';
$objectlabel='Invoice';
$permtoread = $user->rights->facture->lire;
$permtodelete = $user->rights->facture->supprimer;
$uploaddir = $conf->facture->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
if (! $error)
{
$db->commit();
setEventMessage($langs->trans('BillCreated', $nb_bills_created));
}
else
{
$db->rollback();
$action='create';
$_GET["origin"]=$_POST["origin"];
$_GET["originid"]=$_POST["originid"];
setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
}
/* /*
@ -382,6 +610,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
} }
$sql.= $db->plimit($limit+1, $offset); $sql.= $db->plimit($limit+1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
@ -398,6 +627,8 @@ if ($resql)
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
$param=''; $param='';
if ($socid > 0) $param.='&socid='.$socid; if ($socid > 0) $param.='&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
@ -419,6 +650,7 @@ if ($resql)
if ($search_refsupp) $param.="&search_refsupp=".$search_refsupp; if ($search_refsupp) $param.="&search_refsupp=".$search_refsupp;
if ($search_status >= 0) $param.="&search_status=".$search_status; if ($search_status >= 0) $param.="&search_status=".$search_status;
if ($billed != '') $param.="&billed=".$billed; if ($billed != '') $param.="&billed=".$billed;
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss; if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields // Add $param from extra fields
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
@ -428,7 +660,15 @@ if ($resql)
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
} }
//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); // List of mass actions available
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->fournisseur->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->fournisseur->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
// Lignes des champs de filtre // Lignes des champs de filtre
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -440,7 +680,142 @@ if ($resql)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="viewstatut" value="'.$viewstatut.'">'; 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);
// TODO Move this into an invluce
if ($massaction == 'presend')
{
$langs->load("mails");
if (! GETPOST('cancel'))
{
$objecttmp=new CommandeFournisseur($db);
$listofselectedid=array();
$listofselectedthirdparties=array();
$listofselectedref=array();
foreach($arrayofselected as $toselectid)
{
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
$listofselectedid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
$listofselectedthirdparties[$thirdpartyid]=$thirdpartyid;
$listofselectedref[$thirdpartyid][$toselectid]=$objecttmp->ref;
}
}
}
print '<input type="hidden" name="massaction" value="confirm_presend">';
dol_fiche_head(null, '', '');
$topicmail="SendOrderRef";
$modelmail="order_send";
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->withform=-1;
$formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
if($formmail->fromtype === 'user'){
$formmail->fromid = $user->id;
}
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 1)) // If bit 1 is set
{
$formmail->trackid='ord'.$object->id;
}
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{
include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'ord'.$object->id);
}
$formmail->withfrom=1;
$liste=$langs->trans("AllRecipientSelected");
if (count($listofselectedthirdparties) == 1)
{
$liste=array();
$thirdpartyid=array_shift($listofselectedthirdparties);
$soc=new Societe($db);
$soc->fetch($thirdpartyid);
foreach ($soc->thirdparty_and_contact_email_array(1) as $key=>$value)
{
$liste[$key]=$value;
}
$formmail->withtoreadonly=0;
}
else
{
$formmail->withtoreadonly=1;
}
$formmail->withto=$liste;
$formmail->withtofree=0;
$formmail->withtocc=1;
$formmail->withtoccc=$conf->global->MAIN_EMAIL_USECCC;
$formmail->withtopic=$langs->transnoentities($topicmail, '__REF__', '__REFCLIENT__');
$formmail->withfile=$langs->trans("OnlyPDFattachmentSupported");
$formmail->withbody=1;
$formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Tableau des substitutions
$formmail->substit['__REF__']='__REF__'; // We want to keep the tag
$formmail->substit['__SIGNATURE__']=$user->signature;
$formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag
$formmail->substit['__PERSONALIZED__']='';
$formmail->substit['__CONTACTCIVNAME__']='';
// Tableau des parametres complementaires du post
$formmail->param['action']=$action;
$formmail->param['models']=$modelmail;
$formmail->param['models_id']=GETPOST('modelmailselected','int');
$formmail->param['id']=join(',',$arrayofselected);
//$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
print $formmail->get_form();
dol_fiche_end();
}
elseif ($massaction == 'createbills')
{
//var_dump($_REQUEST);
print '<input type="hidden" name="massaction" value="confirm_createbills">';
print '<table class="border" width="100%" >';
print '<tr>';
print '<td class="titlefieldmiddle">';
print $langs->trans('DateInvoice');
print '</td>';
print '<td>';
print $form->select_date('', '', '', '', '', '', 1, 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $langs->trans('CreateOneBillByThird');
print '</td>';
print '<td>';
print $form->selectyesno('createbills_onebythird', '', 1);
print '</td>';
print '</tr>';
print '<tr>';
print '<td>';
print $langs->trans('ValidateInvoices');
print '</td>';
print '<td>';
print $form->selectyesno('valdate_invoices', 1, 1);
print '</td>';
print '</tr>';
print '</table>';
print '<br>';
print '<div class="center">';
print '<input type="submit" class="button" id="createbills" name="createbills" value="'.$langs->trans('CreateInvoiceForThisCustomer').'"> ';
print '<input type="submit" class="button" id="cancel" name="cancel" value="'.$langs->trans('Cancel').'">';
print '</div>';
print '<br>';
}
if ($sall) if ($sall)
{ {
@ -481,6 +856,7 @@ if ($resql)
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint;
if (! empty($moreforfilter)) if (! empty($moreforfilter))
{ {
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
@ -490,6 +866,7 @@ if ($resql)
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1);
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -641,7 +1018,7 @@ if ($resql)
} }
// Action column // Action column
print '<td class="liste_titre" align="middle">'; print '<td class="liste_titre" align="middle">';
$searchpitco=$form->showFilterAndCheckAddButtons(0); $searchpitco=$form->showFilterButtons();
print $searchpitco; print $searchpitco;
print '</td>'; print '</td>';
@ -916,7 +1293,14 @@ if ($resql)
} }
// Action column // Action column
print '<td></td>'; print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$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']++; if (! $i) $totalarray['nbfield']++;
print "</tr>\n"; print "</tr>\n";
@ -926,7 +1310,24 @@ if ($resql)
print '</div>'; print '</div>';
print "</form>\n"; print "</form>\n";
if (! empty($conf->facture->enable)) print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>'; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
/*
* Show list of available documents
*/
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->fournisseur->commande->lire;
$delallowed=$user->rights->fournisseur->commande->lire;
print $formfile->showdocuments('massfilesarea_supplier_order','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else
{
print '<br><a name="show_files"></a><a href="'.$_SERVER["PHP_SELF"].'?show_files=1'.$param.'#show_files">'.$langs->trans("ShowTempMassFilesArea").'</a>';
}
$db->free($resql); $db->free($resql);
} }

View File

@ -1559,7 +1559,7 @@ class Societe extends CommonObject
$note=trim($note); $note=trim($note);
if (! $note) if (! $note)
{ {
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Note")); $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason"));
return -2; return -2;
} }

View File

@ -590,10 +590,10 @@ div.myavailability {
padding-bottom: 4px; padding-bottom: 4px;
} }
.checkallactions { .checkallactions {
vertical-align: text-bottom; /* vertical-align: text-bottom;
margin-top: 6px; margin-top: 6px; */
margin-left: 4px; /* left must be same than right to keep checkbox centered */ margin-left: 2px; /* left must be same than right to keep checkbox centered */
margin-right: 4px; /* left must be same than right to keep checkbox centered */ margin-right: 2px; /* left must be same than right to keep checkbox centered */
} }
.selectlimit, .marginrightonly { .selectlimit, .marginrightonly {
margin-right: 10px !important; margin-right: 10px !important;
@ -607,6 +607,9 @@ div.myavailability {
.strikefordisabled { .strikefordisabled {
text-decoration: line-through; text-decoration: line-through;
} }
.widthdate {
width: 130px;
}
/* using a tdoverflowxxx make the min-width not working */ /* using a tdoverflowxxx make the min-width not working */
.tdoverflow { .tdoverflow {
max-width: 0; max-width: 0;
@ -1611,7 +1614,7 @@ div.login_block {
position: absolute; position: absolute;
text-align: <?php print $right; ?>; text-align: <?php print $right; ?>;
<?php print $right; ?>: 5px; <?php print $right; ?>: 5px;
top: 3px; top: 4px;
font-weight: bold; font-weight: bold;
max-width: <?php echo $maxwidthloginblock; ?>px; max-width: <?php echo $maxwidthloginblock; ?>px;
<?php if (GETPOST("optioncss") == 'print') { ?> <?php if (GETPOST("optioncss") == 'print') { ?>
@ -2346,7 +2349,7 @@ div.refid {
font-size: 160%; font-size: 160%;
} }
div.refidno { div.refidno {
padding-top: 8px; padding-top: 3px;
font-weight: normal; font-weight: normal;
color: #444; color: #444;
font-size: <?php print $fontsize ?>px; font-size: <?php print $fontsize ?>px;
@ -4097,8 +4100,10 @@ ul.ulselectedfields {
} }
dl.dropdown { dl.dropdown {
margin:0px; margin:0px;
margin-left: 2px;
margin-right: 2px;
padding:0px; padding:0px;
vertical-align: middle; vertical-align: text-bottom;
display: inline-block; display: inline-block;
} }
.dropdown dd, .dropdown dt { .dropdown dd, .dropdown dt {
@ -4488,7 +4493,7 @@ div.tabsElem a.tab {
/* nboftopmenuentries = <?php echo $nbtopmenuentries ?>, fontsize=<?php echo $fontsize ?> */ /* nboftopmenuentries = <?php echo $nbtopmenuentries ?>, fontsize=<?php echo $fontsize ?> */
/* rule to reduce top menu - 1st reduction */ /* rule to reduce top menu - 1st reduction */
@media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 6.9, 0) + 20; ?>px) /* reduction 1 */ @media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 6.9, 0) + 24; ?>px) /* reduction 1 */
{ {
div.tmenucenter { div.tmenucenter {
width: <?php echo round($fontsize * 4); ?>px; /* size of viewport */ width: <?php echo round($fontsize * 4); ?>px; /* size of viewport */
@ -4517,7 +4522,7 @@ div.tabsElem a.tab {
} }
} }
/* rule to reduce top menu - 2nd reduction */ /* rule to reduce top menu - 2nd reduction */
@media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 4.9, 0) + 10; ?>px) /* reduction 2 */ @media only screen and (max-width: <?php echo round($nbtopmenuentries * $fontsize * 5, 0) + 24; ?>px) /* reduction 2 */
{ {
div.mainmenu { div.mainmenu {
height: 23px; height: 23px;

View File

@ -596,9 +596,10 @@ div.myavailability {
padding-bottom: 4px; padding-bottom: 4px;
} }
.checkallactions { .checkallactions {
vertical-align: text-bottom; /*vertical-align: text-bottom;
margin-top: 6px; margin-top: 6px;*/
margin-left: 4px; margin-left: 2px; /* left must be same than right to keep checkbox centered */
margin-right: 2px; /* left must be same than right to keep checkbox centered */
} }
.selectlimit, .marginrightonly { .selectlimit, .marginrightonly {
margin-right: 10px !important; margin-right: 10px !important;
@ -612,6 +613,9 @@ div.myavailability {
.strikefordisabled { .strikefordisabled {
text-decoration: line-through; text-decoration: line-through;
} }
.widthdate {
width: 130px;
}
/* using a tdoverflowxxx make the min-width not working */ /* using a tdoverflowxxx make the min-width not working */
.tdoverflow { .tdoverflow {
max-width: 0; max-width: 0;
@ -4219,7 +4223,9 @@ ul.ulselectedfields {
dl.dropdown { dl.dropdown {
margin:0px; margin:0px;
padding:0px; padding:0px;
vertical-align: middle; margin-left: 2px;
margin-right: 2px;
vertical-align: text-bottom;
display: inline-block; display: inline-block;
} }
.dropdown dd, .dropdown dt { .dropdown dd, .dropdown dt {