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
{
print $langs->trans("ThirdpartyNotLinkedToMember");
print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
}
print '</td>';
print "</tr>\n";

View File

@ -107,7 +107,7 @@ if ($socid > 0)
print '<input type="hidden" name="action" value="setremise">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"),0,'company');
dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
@ -119,7 +119,6 @@ if ($socid > 0)
// Discount
print '<tr><td class="titlefield">';
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
print '</table>';
print '<br>';
@ -130,11 +129,11 @@ if ($socid > 0)
print '<table class="border centpercent">';
// 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>';
// 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 "</table>";
@ -179,21 +178,26 @@ if ($socid > 0)
print '<td align="left">'.$langs->trans("NoteReason").'</td>';
print '<td align="center">'.$langs->trans("User").'</td>';
print '</tr>';
$i = 0 ;
$num = $db->num_rows($resql);
while ($i < $num )
{
$obj = $db->fetch_object($resql);
$tag = !$tag;
print '<tr '.$bc[$tag].'>';
print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
print '<td align="left">'.$obj->note.'</td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
print '</tr>';
$i++;
if ($num > 0)
{
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
print '<td align="left">'.$obj->note.'</td>';
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
print '</tr>';
$i++;
}
}
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$db->free($resql);
print "</table>";
}

View File

@ -235,7 +235,7 @@ if ($socid > 0)
print '<input type="hidden" name="action" value="setremise">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"),0,'company');
dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');
@ -274,6 +274,8 @@ if ($socid > 0)
}
print '</table>';
print '</div>';
if ($user->rights->societe->creer)
{
print '<br>';
@ -294,7 +296,6 @@ if ($socid > 0)
print "</table>";
}
print '</div>';
dol_fiche_end();
@ -342,8 +343,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountStillRemaining"));
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td width="120" align="left">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
print '<td align="left">'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="widthdate">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
@ -354,73 +355,79 @@ if ($socid > 0)
$showconfirminfo=array();
$var = true;
$i = 0;
$num = $db->num_rows($resql);
while ($i < $num)
if ($num > 0)
{
$obj = $db->fetch_object($resql);
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
else
{
print '<td>';
print $obj->description;
print '</td>';
}
print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
print '<td align="right">'.price($obj->amount_ht).'</td>';
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
print '<td align="right">'.price($obj->amount_ttc).'</td>';
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
print '</td>';
if ($user->rights->societe->creer || $user->rights->facture->creer)
{
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 ' &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>';
}
else print '<td>&nbsp;</td>';
print '</tr>';
if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
{
$showconfirminfo['rowid']=$obj->rowid;
$showconfirminfo['amount_ttc']=$obj->amount_ttc;
}
$i++;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
else
{
print '<td>';
print $obj->description;
print '</td>';
}
print '<td class="nowrap">'.$langs->trans("NotConsumed").'</td>';
print '<td align="right">'.price($obj->amount_ht).'</td>';
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
print '<td align="right">'.price($obj->amount_ttc).'</td>';
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
print '</td>';
if ($user->rights->societe->creer || $user->rights->facture->creer)
{
print '<td class="nowrap">';
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 '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>';
}
else print '<td>&nbsp;</td>';
print '</tr>';
if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
{
$showconfirminfo['rowid']=$obj->rowid;
$showconfirminfo['amount_ttc']=$obj->amount_ttc;
}
$i++;
}
}
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
$db->free($resql);
print "</table>";
@ -491,8 +498,8 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("DiscountAlreadyCounted"));
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td width="120" align="left">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
print '<td align="left">'.$langs->trans("ReasonDiscount").'</td>';
print '<td class="widthdate">'.$langs->trans("Date").'</td>'; // Need 120+ for format with AM/PM
print '<td>'.$langs->trans("ReasonDiscount").'</td>';
print '<td width="150" class="nowrap">'.$langs->trans("ConsumedBy").'</td>';
print '<td width="120" align="right">'.$langs->trans("AmountHT").'</td>';
print '<td width="80" align="right">'.$langs->trans("VATRate").'</td>';
@ -501,15 +508,17 @@ if ($socid > 0)
print '<td width="50">&nbsp;</td>';
print '</tr>';
$var = true;
$tab_sqlobj=array();
$tab_sqlobjOrder=array();
$num = $db->num_rows($resql);
for ($i = 0;$i < $num;$i++)
if ($num > 0)
{
$sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
for ($i = 0;$i < $num; $i++)
{
$sqlobj = $db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj;
$tab_sqlobjOrder[]=$db->jdate($sqlobj->dc);
}
}
$db->free($resql);
@ -524,57 +533,64 @@ if ($socid > 0)
array_multisort($tab_sqlobjOrder,SORT_DESC,$tab_sqlobj);
$num = count($tab_sqlobj);
$i = 0 ;
while ($i < $num )
if ($num > 0)
{
$obj = array_shift($tab_sqlobj);
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
else
{
print '<td>';
print $obj->description;
print '</td>';
}
print '<td align="left" class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
print '<td align="right">'.price($obj->amount_ht).'</td>';
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
print '<td align="right">'.price($obj->amount_ttc).'</td>';
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
print '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$i++;
$i = 0 ;
while ($i < $num )
{
$obj = array_shift($tab_sqlobj);
print '<tr class="oddeven">';
print '<td>'.dol_print_date($db->jdate($obj->dc),'dayhour').'</td>';
if (preg_match('/\(CREDIT_NOTE\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(CREDIT_NOTE\)/',$langs->trans("CreditNote"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(DEPOSIT\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(DEPOSIT\)/',$langs->trans("InvoiceDeposit"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
elseif (preg_match('/\(EXCESS RECEIVED\)/',$obj->description))
{
print '<td class="nowrap">';
$facturestatic->id=$obj->fk_facture_source;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1);
print '</td>';
}
else
{
print '<td>';
print $obj->description;
print '</td>';
}
print '<td align="left" class="nowrap"><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
print '<td align="right">'.price($obj->amount_ht).'</td>';
print '<td align="right">'.price2num($obj->tva_tx,'MU').'%</td>';
print '<td align="right">'.price($obj->amount_ttc).'</td>';
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
print '</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$i++;
}
}
else
{
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
}
print "</table>";
}
else

View File

@ -199,227 +199,226 @@ if (empty($reshook))
$permtodelete = $user->rights->commande->supprimer;
$uploaddir = $conf->commande->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
if ($massaction == 'confirm_createbills') {
$orders = GETPOST('toselect');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$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))
{
$datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
}
$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))
{
$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++;
}
// TODO Move this into mass action include
if ($massaction == 'confirm_createbills') {
$orders = GETPOST('toselect');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$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))
{
$datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
}
$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))
{
$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++;
}
}
}
@ -435,8 +434,9 @@ $formfile = new FormFile($db);
$companystatic = new Societe($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";
llxHeader('',$langs->trans("Orders"),$help_url);
llxHeader('',$title,$help_url);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
@ -622,7 +622,6 @@ if ($resql)
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($billed != '') $param.='&billed='.$billed;
// Add $param from extra fields
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);
// TODO Move this into an invluce
if ($massaction == 'presend')
{
$langs->load("mails");
@ -679,9 +679,6 @@ if ($resql)
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, '', '');
$topicmail="SendOrderRef";
@ -1428,8 +1425,6 @@ if ($resql)
print '</form>'."\n";
//print '<br>'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'<br>';
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
/*

View File

@ -6218,7 +6218,7 @@ class Form
global $conf, $langs;
$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">
$(document).ready(function() {
$("#checkallactions").click(function() {

View File

@ -312,7 +312,7 @@ class FormFile
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.='<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -337,7 +337,7 @@ class FormFile
$titletoshow=$langs->trans("Documents");
if (! empty($title)) $titletoshow=$title;
// Show table
if ($genallowed)
{
@ -461,7 +461,7 @@ class FormFile
$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;
else
@ -470,7 +470,7 @@ class FormFile
$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;
else
@ -688,7 +688,7 @@ class FormFile
{
$headershown=1;
$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

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;
}
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
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);
}
/**
* 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 "?"
*

View File

@ -48,6 +48,12 @@ $langs->load('compta');
$langs->load('bills');
$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");
$ordermonth=GETPOST("ordermonth","int");
$orderday=GETPOST("orderday","int");
@ -92,7 +98,7 @@ $orderid = GETPOST('orderid','int');
if ($user->societe_id) $socid=$user->societe_id;
$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;
$sortfield = GETPOST("sortfield",'alpha');
@ -172,63 +178,285 @@ $parameters=array('socid'=>$socid);
$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');
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// 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
{
$ordermonth='';
$orderyear='';
$orderday='';
$search_categ='';
$search_user='';
$search_sale='';
$search_product_category='';
$search_ref='';
$search_refsupp='';
$search_company='';
$search_town='';
$search_zip="";
$search_state="";
$search_type='';
$search_country='';
$search_type_thirdparty='';
$search_request_author='';
$search_total_ht='';
$search_total_vat='';
$search_total_ttc='';
$search_status=-1;
$orderyear='';
$ordermonth='';
$orderday='';
$deliveryday='';
$deliverymonth='';
$deliveryyear='';
$billed='';
$search_project_ref='';
$search_array_options=array();
}
if (empty($reshook))
{
// Mass actions. Controls on number of lines checked
$maxformassaction=1000;
if (! empty($massaction) && count($toselect) < 1)
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers
{
$error++;
setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
}
if (! $error && count($toselect) > $maxformassaction)
{
setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
$error++;
$ordermonth='';
$orderyear='';
$orderday='';
$search_categ='';
$search_user='';
$search_sale='';
$search_product_category='';
$search_ref='';
$search_refsupp='';
$search_company='';
$search_town='';
$search_zip="";
$search_state="";
$search_type='';
$search_country='';
$search_type_thirdparty='';
$search_request_author='';
$search_total_ht='';
$search_total_vat='';
$search_total_ttc='';
$search_status=-1;
$orderyear='';
$ordermonth='';
$orderday='';
$deliveryday='';
$deliverymonth='';
$deliveryyear='';
$billed='';
$toselect='';
$search_project_ref='';
$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';
}
// 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')
{
$orders = GETPOST('toselect');
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
$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))
{
$datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y"));
}
$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))
{
$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++;
}
}
}
/*
* View
*/
@ -382,6 +610,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
}
$sql.= $db->plimit($limit+1, $offset);
$resql = $db->query($sql);
if ($resql)
{
@ -398,6 +627,8 @@ if ($resql)
$num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
$param='';
if ($socid > 0) $param.='&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
@ -419,7 +650,8 @@ if ($resql)
if ($search_refsupp) $param.="&search_refsupp=".$search_refsupp;
if ($search_status >= 0) $param.="&search_status=".$search_status;
if ($billed != '') $param.="&billed=".$billed;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
if ($show_files) $param.='&show_files=' .$show_files;
if ($optioncss != '') $param.='&optioncss='.$optioncss;
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
{
@ -428,8 +660,16 @@ 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")));
// 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
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -440,8 +680,143 @@ 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);
// 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)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
@ -481,6 +856,7 @@ if ($resql)
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (! empty($moreforfilter))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">';
@ -490,6 +866,7 @@ if ($resql)
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$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 '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
@ -641,7 +1018,7 @@ if ($resql)
}
// Action column
print '<td class="liste_titre" align="middle">';
$searchpitco=$form->showFilterAndCheckAddButtons(0);
$searchpitco=$form->showFilterButtons();
print $searchpitco;
print '</td>';
@ -916,7 +1293,14 @@ if ($resql)
}
// 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']++;
print "</tr>\n";
@ -926,8 +1310,25 @@ if ($resql)
print '</div>';
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);
}
else

View File

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

View File

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

View File

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