|
@@ -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");
|
|
|
+ $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';
|
|
|
}
|
|
|
- if (! $error && count($toselect) > $maxformassaction)
|
|
|
+
|
|
|
+ // 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')
|
|
|
{
|
|
|
- setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
|
|
|
- $error++;
|
|
|
+ $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('&','&',$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
|