'."\n";
@@ -992,7 +992,7 @@ if ($resql)
}
// Action column
print '| ';
- $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
+ $searchpitco=$form->showFilterButtons();
print $searchpitco;
print ' | ';
@@ -1222,7 +1222,7 @@ if ($resql)
// Third party
if (! empty($arrayfields['s.nom']['checked']))
{
- print '';
+ print ' | ';
print $companystatic->getNomUrl(1,'customer');
// If module invoices enabled and user with invoice creation permissions
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 03612cbb932..92fcf4fc511 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -738,7 +738,8 @@ 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 '';
print ' '."\n";
@@ -748,14 +749,14 @@ if ($resql)
if (! empty($arrayfields['f.facnumber']['checked']))
{
print '| ';
- print '';
+ print '';
print ' | ';
}
// Ref customer
if (! empty($arrayfields['f.ref_client']['checked']))
{
print '';
- print '';
+ print '';
print ' | ';
}
// Type
@@ -776,8 +777,8 @@ if ($resql)
if (! empty($arrayfields['f.date']['checked']))
{
print '';
- if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '';
- print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '';
+ print '';
$formother->select_year($year?$year:-1,'year',1, 20, 5);
print ' | ';
}
@@ -785,8 +786,8 @@ if ($resql)
if (! empty($arrayfields['f.date_lim_reglement']['checked']))
{
print '';
- if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '';
- print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '';
+ print '';
$formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5);
print ' '.$langs->trans("Late");
print ' | ';
@@ -797,9 +798,9 @@ if ($resql)
print ' | ';
}
// Town
- if (! empty($arrayfields['s.town']['checked'])) print ' | ';
+ if (! empty($arrayfields['s.town']['checked'])) print ' | ';
// Zip
- if (! empty($arrayfields['s.zip']['checked'])) print ' | ';
+ if (! empty($arrayfields['s.zip']['checked'])) print ' | ';
// State
if (! empty($arrayfields['state.nom']['checked']))
{
@@ -832,21 +833,21 @@ if ($resql)
{
// Amount
print '';
- print '';
+ print '';
print ' | ';
}
if (! empty($arrayfields['f.total_vat']['checked']))
{
// Amount
print '';
- print '';
+ print '';
print ' | ';
}
if (! empty($arrayfields['f.total_ttc']['checked']))
{
// Amount
print '';
- print '';
+ print '';
print ' | ';
}
if (! empty($arrayfields['dynamount_payed']['checked']))
@@ -908,7 +909,7 @@ if ($resql)
}
// Action column
print '';
- $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
+ $searchpitco=$form->showFilterButtons();
print $searchpitco;
print ' | ';
print "\n";
@@ -956,12 +957,10 @@ if ($resql)
if ($num > 0)
{
$i=0;
- $var=true;
$totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
- $var=!$var;
$datelimit=$db->jdate($obj->datelimite);
$facturestatic->id=$obj->facid;
@@ -978,7 +977,7 @@ if ($resql)
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = $obj->total_ttc - $totalpay;
- print '';
+ print ' ';
if (! empty($arrayfields['f.facnumber']['checked']))
{
print '| ';
@@ -1045,7 +1044,7 @@ if ($resql)
// Third party
if (! empty($arrayfields['s.nom']['checked']))
{
- print ' | ';
+ print ' | ';
$thirdparty=new Societe($db);
$thirdparty->id=$obj->socid;
$thirdparty->name=$obj->name;
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 647d0cf6a76..73e854248fe 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -871,8 +871,12 @@ class FormFile
else $this->infofiles['extensions'][$ext]++;
// Preview
- $urladvanced = getAdvancedPreviewUrl($modulepart, $relativepath);
- if ($urladvanced) $tmpout.= ''.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'';
+ if (! empty($conf->use_javascript_ajax) && ! empty($conf->browser->layout != 'phone'))
+ {
+ $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1);
+ if ($tmparray && $tmparray['url']) $tmpout.= ''.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'';
+ }
+
// Download
$tmpout.= 'login);
}
- if( $this->invoice->delete($id) < 0)
+ if( $this->invoice->delete(DolibarrApiAccess::$user) < 0)
{
throw new RestException(500);
}
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 1da9854791b..7b732dd05a6 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1724,28 +1724,31 @@ class CommandeFournisseur extends CommonOrder
* Delete an order
*
* @param User $user Object user
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
- public function delete($user='')
+ public function delete(User $user, $notrigger=0)
{
global $langs,$conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error = 0;
- // Call trigger
- $result=$this->call_trigger('ORDER_SUPPLIER_DELETE',$user);
- if ($result < 0)
- {
- $this->errors[]='ErrorWhenRunningTrigger';
- dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
- return -1;
- }
- // End call triggers
-
-
$this->db->begin();
+ if (empty($notrigger))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_SUPPLIER_DELETE',$user);
+ if ($result < 0)
+ {
+ $this->errors[]='ErrorWhenRunningTrigger';
+ dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
+ return -1;
+ }
+ // End call triggers
+ }
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =". $this->id ;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (! $this->db->query($sql) )
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 5f435da9daf..42daafe9c2d 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -849,14 +849,15 @@ class FactureFournisseur extends CommonInvoice
/**
* Delete invoice from database
*
- * @param int $rowid Id of invoice to delete
+ * @param User $user User object
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, >0 if OK
*/
- public function delete($rowid)
+ public function delete(User $user, $notrigger=0)
{
- global $user,$langs,$conf;
+ global $langs,$conf;
- if (! $rowid) $rowid=$this->id;
+ $rowid=$this->id;
dol_syslog("FactureFournisseur::delete rowid=".$rowid, LOG_DEBUG);
@@ -865,22 +866,37 @@ class FactureFournisseur extends CommonInvoice
$error=0;
$this->db->begin();
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
- dol_syslog(get_class($this)."::delete", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
+ if (! $error && ! $notrigger)
{
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
+ // Call trigger
+ $result=$this->call_trigger('BILL_SUPPLIER_DELETE',$user);
+ if ($result < 0)
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ // Fin appel triggers
+ }
+
+ if (! $error)
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn_det WHERE fk_facture_fourn = '.$rowid.';';
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
- $resql2 = $this->db->query($sql);
- if (! $resql2) {
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture_fourn WHERE rowid = '.$rowid;
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
+ $resql2 = $this->db->query($sql);
+ if (! $resql2) {
+ $error++;
+ }
+ }
+ else {
$error++;
}
}
- else {
- $error++;
- }
-
+
if (! $error)
{
// Delete linked object
@@ -888,18 +904,6 @@ class FactureFournisseur extends CommonInvoice
if ($res < 0) $error++;
}
- if (! $error)
- {
- // Call trigger
- $result=$this->call_trigger('BILL_SUPPLIER_DELETE',$user);
- if ($result < 0)
- {
- $this->db->rollback();
- return -1;
- }
- // Fin appel triggers
- }
-
if (! $error)
{
// Delete linked object
@@ -2452,13 +2456,11 @@ class SupplierInvoiceLine extends CommonObjectLine
/**
* Deletes a line
*
- * @param bool|int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @param bool|int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int 0 if KO, 1 if OK
*/
public function delete($notrigger = 0)
{
- global $user;
-
dol_syslog(get_class($this)."::deleteline rowid=".$this->id, LOG_DEBUG);
$error = 0;
diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php
index be87fbc7512..12fccab91d8 100644
--- a/htdocs/fourn/class/paiementfourn.class.php
+++ b/htdocs/fourn/class/paiementfourn.class.php
@@ -349,7 +349,7 @@ class PaiementFourn extends Paiement
$result=$accline->fetch($bank_line_id);
if ($result > 0) // If result = 0, record not found, we don't try to delete
{
- $result=$accline->delete();
+ $result=$accline->delete($user);
}
if ($result < 0)
{
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index 52320ec9580..1eb2dfaeb4a 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -48,6 +48,12 @@ $langs->load("companies");
$langs->load('products');
$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');
+
$socid = GETPOST('socid','int');
// Security check
@@ -110,7 +116,7 @@ if (! $sortfield) $sortfield="f.datef,f.rowid";
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$contextpage='supplierinvoicelist';
-$diroutputmassaction=$conf->facture->dir_output . '/temp/massgeneration/'.$user->id;
+$diroutputmassaction=$conf->fournisseur->facture->dir_output . '/temp/massgeneration/'.$user->id;
$object=new FactureFournisseur($db);
@@ -171,67 +177,62 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
*/
if (GETPOST('cancel')) { $action='list'; $massaction=''; }
-if (! GETPOST('confirmmassaction')) { $massaction=''; }
+if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
$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';
-
-if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All test must be present to be compatible with all browsers
-{
- $search_all="";
- $search_user='';
- $search_sale='';
- $search_product_category='';
- $search_ref="";
- $search_refsupplier="";
- $search_label="";
- $search_project='';
- $search_societe="";
- $search_company="";
- $search_amount_no_tax="";
- $search_amount_all_tax="";
- $search_montant_ht='';
- $search_montant_vat='';
- $search_montant_ttc='';
- $search_status='';
- $search_paymentmode='';
- $search_town='';
- $search_zip="";
- $search_state="";
- $search_type='';
- $search_country='';
- $search_type_thirdparty='';
- $year="";
- $month="";
- $day="";
- $year_lim="";
- $month_lim="";
- $day_lim="";
- $search_array_options=array();
- $filter='';
- $option='';
-}
-
if (empty($reshook))
{
- // Mass actions. Controls on number of lines checked
- $maxformassaction=1000;
- if (! empty($massaction) && count($toselect) < 1)
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOST("button_removefilter.x")) // All test must be present to be compatible with all browsers
{
- $error++;
- setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
+ $search_all="";
+ $search_user='';
+ $search_sale='';
+ $search_product_category='';
+ $search_ref="";
+ $search_refsupplier="";
+ $search_label="";
+ $search_project='';
+ $search_societe="";
+ $search_company="";
+ $search_amount_no_tax="";
+ $search_amount_all_tax="";
+ $search_montant_ht='';
+ $search_montant_vat='';
+ $search_montant_ttc='';
+ $search_status='';
+ $search_paymentmode='';
+ $search_town='';
+ $search_zip="";
+ $search_state="";
+ $search_type='';
+ $search_country='';
+ $search_type_thirdparty='';
+ $year="";
+ $month="";
+ $day="";
+ $year_lim="";
+ $month_lim="";
+ $day_lim="";
+ $toselect='';
+ $search_array_options=array();
+ $filter='';
+ $option='';
}
- if (! $error && count($toselect) > $maxformassaction)
- {
- setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors');
- $error++;
- }
-
-
+
+ // Mass actions
+ $objectclass='FactureFournisseur';
+ $objectlabel='SupplierInvoices';
+ $permtoread = $user->rights->fournisseur->facture->lire;
+ $permtodelete = $user->rights->fournisseur->facture->supprimer;
+ $uploaddir = $conf->fournisseur->facture->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
+
/*
* View
@@ -424,7 +425,15 @@ 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->facture->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
+ //if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
+ $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$i = 0;
print ' | |