Merge remote-tracking branch 'upstream/develop' into actionrefused

This commit is contained in:
Frédéric FRANCE 2018-11-15 22:15:45 +01:00
commit ce6b7adaa0
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
32 changed files with 743 additions and 329 deletions

View File

@ -69,7 +69,15 @@ class BookKeeping extends CommonObject
public $doc_date; public $doc_date;
public $date_lim_reglement; public $date_lim_reglement;
public $doc_type;
/**
* @var string doc_type
*/
public $doc_type;
/**
* @var string doc_ref
*/
public $doc_ref; public $doc_ref;
/** /**
@ -82,12 +90,35 @@ class BookKeeping extends CommonObject
*/ */
public $fk_docdet; public $fk_docdet;
public $thirdparty_code; /**
* @var string thirdparty code
*/
public $thirdparty_code;
/**
* @var string subledger account
*/
public $subledger_account; public $subledger_account;
/**
* @var string subledger label
*/
public $subledger_label; public $subledger_label;
/**
* @var string doc_type
*/
public $numero_compte; public $numero_compte;
public $label_compte;
public $label_operation; /**
* @var string label compte
*/
public $label_compte;
/**
* @var string label operation
*/
public $label_operation;
public $debit; public $debit;
public $credit; public $credit;
public $montant; public $montant;

View File

@ -426,7 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Add filter // Add filter
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$arrayoftypes=array('from'=>'MailFrom', 'to'=>'MailTo', 'cc'=>'Cc', 'bcc'=>'Bcc', 'subject'=>'Subject', 'body'=>'Body', 'seen'=>'AlreadyRead', 'unseen'=>'NotRead'); $arrayoftypes=array('from'=>'MailFrom', 'to'=>'MailTo', 'cc'=>'Cc', 'bcc'=>'Bcc', 'subject'=>'Subject', 'body'=>'Body', 'seen'=>'AlreadyRead', 'unseen'=>'NotRead', 'withtrackingid'=>'WithDolTrackingID', 'withouttrackingid'=>'WithoutDolTrackingID');
print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1); print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1);
print '</td><td>'; print '</td><td>';
print '<input type="text" name="rulevalue">'; print '<input type="text" name="rulevalue">';
@ -464,7 +464,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Add operation // Add operation
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
$arrayoftypes=array('recordevent'=>'RecordEvent'); $arrayoftypes=array('loadthirdparty'=>'LoadThirdPartyFromName', 'loadandcreatethirdparty'=>'LoadThirdPartyFromNameOrCreate', 'recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty'; if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty';
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1); print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1);
print '</td><td>'; print '</td><td>';

View File

@ -232,13 +232,13 @@ print '</td>';
print '</tr>'; print '</tr>';
//EntToEnd //EntToEnd
print '<tr class="pair"><td class="fieldrequired">'.$langs->trans("END_TO_END").'</td>'; print '<tr class="pair"><td>'.$langs->trans("END_TO_END").'</td>';
print '<td align="left">'; print '<td align="left">';
print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->END_TO_END.'" size="15" ></td>'; print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->END_TO_END.'" size="15" ></td>';
print '</td></tr>'; print '</td></tr>';
//USTRD //USTRD
print '<tr class="pair"><td class="fieldrequired">'.$langs->trans("USTRD").'</td>'; print '<tr class="pair"><td>'.$langs->trans("USTRD").'</td>';
print '<td align="left">'; print '<td align="left">';
print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->USTRD.'" size="15" ></td>'; print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->USTRD.'" size="15" ></td>';
print '</td></tr>'; print '</td></tr>';

View File

@ -380,6 +380,7 @@ if (empty($reshook))
} }
} else { } else {
$object->ref = GETPOST('ref'); $object->ref = GETPOST('ref');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
$object->ref_client = GETPOST('ref_client'); $object->ref_client = GETPOST('ref_client');
$object->datep = $datep; $object->datep = $datep;
$object->date_livraison = $date_delivery; $object->date_livraison = $date_delivery;

View File

@ -874,6 +874,7 @@ class Propal extends CommonObject
$now=dol_now(); $now=dol_now();
// Clean parameters // Clean parameters
if (empty($this->entity)) $this->entity = $conf->entity;
if (empty($this->date)) $this->date=$this->datep; if (empty($this->date)) $this->date=$this->datep;
$this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600); $this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
if (empty($this->availability_id)) $this->availability_id=0; if (empty($this->availability_id)) $this->availability_id=0;
@ -983,7 +984,7 @@ class Propal extends CommonObject
$sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".($this->fk_project?$this->fk_project:"null");
$sql.= ", ".(int) $this->fk_incoterms; $sql.= ", ".(int) $this->fk_incoterms;
$sql.= ", '".$this->db->escape($this->location_incoterms)."'"; $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
$sql.= ", ".$conf->entity; $sql.= ", ".$this->entity;
$sql.= ", ".(int) $this->fk_multicurrency; $sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; $sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx; $sql.= ", ".(double) $this->multicurrency_tx;
@ -3428,13 +3429,7 @@ class Propal extends CommonObject
global $conf,$langs; global $conf,$langs;
$langs->load("propal"); $langs->load("propal");
$constant = 'PROPALE_ADDON_'.$this->entity; $classname = $conf->global->PROPALE_ADDON;
if (! empty($conf->global->$constant)) {
$classname = $conf->global->$constant; // for multicompany proposal sharing
} else {
$classname = $conf->global->PROPALE_ADDON;
}
if (! empty($classname)) if (! empty($classname))
{ {

View File

@ -109,9 +109,23 @@ if ($id > 0 || ! empty($ref)) {
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('invoicecard','globalcard')); $hookmanager->initHooks(array('invoicecard','globalcard'));
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $usercanread = $user->rights->facture->lire;
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $usercancreate = $user->rights->facture->creer;
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php $usercanissuepayment = $user->rights->facture->paiement;
$usercandelete = $user->rights->facture->supprimer;
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)));
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send);
$usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen);
$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)));
$usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
$usercancreatemargin = $user->rights->margins->creer;
$usercanreadallmargin = $user->rights->margins->liretous;
$usercancreatewithdrarequest = $user->rights->prelevement->bons->creer;
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdonw.inc.php
// Security check // Security check
$fieldid = (! empty($ref) ? 'facnumber' : 'rowid'); $fieldid = (! empty($ref) ? 'facnumber' : 'rowid');
@ -147,7 +161,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) {
// if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { // if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) {
// $mesgs [] = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>'; // $mesgs [] = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>';
// } else { // } else {
@ -165,7 +179,7 @@ if (empty($reshook))
} }
// Change status of invoice // Change status of invoice
else if ($action == 'reopen' && $user->rights->facture->creer) { else if ($action == 'reopen' && $usercancreate) {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced') || ($object->statut == 1 && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted if ($object->statut == 2 || ($object->statut == 3 && $object->close_code != 'replaced') || ($object->statut == 1 && $object->paye == 1)) { // ($object->statut == 1 && $object->paye == 1) should not happened but can be found when data are corrupted
$result = $object->set_unpaid($user); $result = $object->set_unpaid($user);
@ -194,8 +208,8 @@ if (empty($reshook))
$isErasable=$object->is_erasable(); $isErasable=$object->is_erasable();
if (($user->rights->facture->supprimer && $isErasable > 0) if (($usercandelete && $isErasable > 0)
|| ($user->rights->facture->creer && $isErasable == 1)) || ($usercancreate && $isErasable == 1))
{ {
$result = $object->delete($user, 0, $idwarehouse); $result = $object->delete($user, 0, $idwarehouse);
if ($result > 0) { if ($result > 0) {
@ -209,7 +223,7 @@ if (empty($reshook))
} }
// Delete line // Delete line
else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -243,7 +257,7 @@ if (empty($reshook))
} }
// Delete link of credit note to invoice // Delete link of credit note to invoice
else if ($action == 'unlinkdiscount' && $user->rights->facture->creer) else if ($action == 'unlinkdiscount' && $usercancreate)
{ {
$discount = new DiscountAbsolute($db); $discount = new DiscountAbsolute($db);
$result = $discount->fetch(GETPOST("discountid")); $result = $discount->fetch(GETPOST("discountid"));
@ -251,7 +265,7 @@ if (empty($reshook))
} }
// Validation // Validation
else if ($action == 'valid' && $user->rights->facture->creer) else if ($action == 'valid' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
@ -271,7 +285,7 @@ if (empty($reshook))
} }
} }
else if ($action == 'set_thirdparty' && $user->rights->facture->creer) else if ($action == 'set_thirdparty' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY'); $object->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY');
@ -280,13 +294,13 @@ if (empty($reshook))
exit(); exit();
} }
else if ($action == 'classin' && $user->rights->facture->creer) else if ($action == 'classin' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->setProject($_POST['projectid']); $object->setProject($_POST['projectid']);
} }
else if ($action == 'setmode' && $user->rights->facture->creer) else if ($action == 'setmode' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
@ -295,16 +309,16 @@ if (empty($reshook))
} }
// Multicurrency Code // Multicurrency Code
else if ($action == 'setmulticurrencycode' && $user->rights->facture->creer) { else if ($action == 'setmulticurrencycode' && $usercancreate) {
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
} }
// Multicurrency rate // Multicurrency rate
else if ($action == 'setmulticurrencyrate' && $user->rights->facture->creer) { else if ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} }
else if ($action == 'setinvoicedate' && $user->rights->facture->creer) else if ($action == 'setinvoicedate' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$old_date_lim_reglement = $object->date_lim_reglement; $old_date_lim_reglement = $object->date_lim_reglement;
@ -323,7 +337,7 @@ if (empty($reshook))
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} }
else if ($action == 'setdate_pointoftax' && $user->rights->facture->creer) else if ($action == 'setdate_pointoftax' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
@ -332,7 +346,7 @@ if (empty($reshook))
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} }
else if ($action == 'setconditions' && $user->rights->facture->creer) else if ($action == 'setconditions' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->cond_reglement_code = 0; // To clean property $object->cond_reglement_code = 0; // To clean property
@ -348,7 +362,7 @@ if (empty($reshook))
if ($result < 0) dol_print_error($db, $object->error); if ($result < 0) dol_print_error($db, $object->error);
} }
else if ($action == 'setpaymentterm' && $user->rights->facture->creer) else if ($action == 'setpaymentterm' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']); $object->date_lim_reglement = dol_mktime(12, 0, 0, $_POST['paymenttermmonth'], $_POST['paymenttermday'], $_POST['paymenttermyear']);
@ -361,7 +375,7 @@ if (empty($reshook))
dol_print_error($db, $object->error); dol_print_error($db, $object->error);
} }
else if ($action == 'setrevenuestamp' && $user->rights->facture->creer) else if ($action == 'setrevenuestamp' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->revenuestamp = GETPOST('revenuestamp'); $object->revenuestamp = GETPOST('revenuestamp');
@ -378,18 +392,18 @@ if (empty($reshook))
} }
// bank account // bank account
else if ($action == 'setbankaccount' && $user->rights->facture->creer) else if ($action == 'setbankaccount' && $usercancreate)
{ {
$result=$object->setBankAccount(GETPOST('fk_account', 'int')); $result=$object->setBankAccount(GETPOST('fk_account', 'int'));
} }
else if ($action == 'setremisepercent' && $user->rights->facture->creer) else if ($action == 'setremisepercent' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->set_remise($user, $_POST['remise_percent']); $result = $object->set_remise($user, $_POST['remise_percent']);
} }
else if ($action == "setabsolutediscount" && $user->rights->facture->creer) else if ($action == "setabsolutediscount" && $usercancreate)
{ {
// POST[remise_id] or POST[remise_id_for_payment] // POST[remise_id] or POST[remise_id_for_payment]
@ -447,17 +461,14 @@ if (empty($reshook))
} }
} }
else if ($action == 'setref_client' && $user->rights->facture->creer) else if ($action == 'setref_client' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->set_ref_client(GETPOST('ref_client')); $object->set_ref_client(GETPOST('ref_client'));
} }
// Classify to validated // Classify to validated
else if ($action == 'confirm_valid' && $confirm == 'yes' && else if ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate)
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)))
)
{ {
$idwarehouse = GETPOST('idwarehouse','int'); $idwarehouse = GETPOST('idwarehouse','int');
@ -557,10 +568,7 @@ if (empty($reshook))
} }
// Go back to draft status (unvalidate) // Go back to draft status (unvalidate)
else if ($action == 'confirm_modif' && else if ($action == 'confirm_modif' && $usercanunvalidate)
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
)
{ {
$idwarehouse = GETPOST('idwarehouse','int'); $idwarehouse = GETPOST('idwarehouse','int');
@ -640,13 +648,13 @@ if (empty($reshook))
} }
// Classify "paid" // Classify "paid"
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) else if ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment)
{ {
$object->fetch($id); $object->fetch($id);
$result = $object->set_paid($user); $result = $object->set_paid($user);
if ($result<0) setEventMessages($object->error, $object->errors, 'errors'); if ($result<0) setEventMessages($object->error, $object->errors, 'errors');
} // Classif "paid partialy" } // Classif "paid partialy"
else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $usercanissuepayment)
{ {
$object->fetch($id); $object->fetch($id);
$close_code = GETPOST("close_code",'none'); $close_code = GETPOST("close_code",'none');
@ -671,7 +679,7 @@ if (empty($reshook))
} }
// Convertir en reduc // Convertir en reduc
else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -797,7 +805,7 @@ if (empty($reshook))
} }
// Delete payment // Delete payment
elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $user->rights->facture->creer) elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate)
{ {
$object->fetch($id); $object->fetch($id);
if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0)
@ -817,7 +825,7 @@ if (empty($reshook))
/* /*
* Insert new invoice in database * Insert new invoice in database
*/ */
else if ($action == 'add' && $user->rights->facture->creer) else if ($action == 'add' && $usercancreate)
{ {
if ($socid > 0) $object->socid = GETPOST('socid', 'int'); if ($socid > 0) $object->socid = GETPOST('socid', 'int');
@ -869,6 +877,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Proprietes particulieres a facture de remplacement // Proprietes particulieres a facture de remplacement
$object->fk_facture_source = $_POST['fac_replacement']; $object->fk_facture_source = $_POST['fac_replacement'];
@ -921,6 +930,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Proprietes particulieres a facture avoir // Proprietes particulieres a facture avoir
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
@ -1102,6 +1112,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
// Source facture // Source facture
$object->fac_rec = GETPOST('fac_rec', 'int'); $object->fac_rec = GETPOST('fac_rec', 'int');
@ -1152,6 +1163,7 @@ if (empty($reshook))
$object->location_incoterms = GETPOST('location_incoterms', 'alpha'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
if (GETPOST('type') == Facture::TYPE_SITUATION) if (GETPOST('type') == Facture::TYPE_SITUATION)
{ {
@ -1634,7 +1646,7 @@ if (empty($reshook))
} }
// Add a new line // Add a new line
else if ($action == 'addline' && $user->rights->facture->creer) else if ($action == 'addline' && $usercancreate)
{ {
$langs->load('errors'); $langs->load('errors');
$error = 0; $error = 0;
@ -1967,7 +1979,7 @@ if (empty($reshook))
if ($tva_npr) if ($tva_npr)
$info_bits |= 0x01; $info_bits |= 0x01;
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) { if ($usercanproductignorepricemin && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
setEventMessages($mesg, null, 'errors'); setEventMessages($mesg, null, 'errors');
} else { } else {
@ -2039,7 +2051,7 @@ if (empty($reshook))
} }
} }
elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel','alpha')) elseif ($action == 'updateline' && $usercancreate && ! GETPOST('cancel','alpha'))
{ {
if (! $object->fetch($id) > 0) dol_print_error($db); if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -2130,7 +2142,7 @@ if (empty($reshook))
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
// Check price is not lower than minimum (check is done only for standard or replacement invoices) // Check price is not lower than minimum (check is done only for standard or replacement invoices)
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) ) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) { if ($usercanproductignorepricemin && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min)))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
$error++; $error++;
} }
@ -2167,7 +2179,7 @@ if (empty($reshook))
// Update line // Update line
if (! $error) { if (! $error) {
if (empty($user->rights->margins->creer)) if (empty($usercancreatemargin))
{ {
foreach ($object->lines as &$line) foreach ($object->lines as &$line)
{ {
@ -2245,7 +2257,7 @@ if (empty($reshook))
} }
} }
else if ($action == 'updatealllines' && $user->rights->facture->creer && $_POST['all_percent'] == $langs->trans('Modifier')) else if ($action == 'updatealllines' && $usercancreate && $_POST['all_percent'] == $langs->trans('Modifier'))
{ {
if (!$object->fetch($id) > 0) dol_print_error($db); if (!$object->fetch($id) > 0) dol_print_error($db);
if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "") if (!is_null(GETPOST('all_progress')) && GETPOST('all_progress') != "")
@ -2262,23 +2274,22 @@ if (empty($reshook))
} }
} }
else if ($action == 'updateline' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel')) { else if ($action == 'updateline' && $usercancreate && $_POST['cancel'] == $langs->trans('Cancel')) {
header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id); // Pour reaffichage de la fiche en cours d'edition
exit(); exit();
} }
// Outing situation invoice from cycle // Outing situation invoice from cycle
elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $user->rights->facture->creer) elseif ($action == 'confirm_situationout' && $confirm == 'yes' && $usercancreate)
{ {
$object->fetch($id,'', '','', true); $object->fetch($id,'', '','', true);
if ($object->statut == Facture::STATUS_VALIDATED if ($object->statut == Facture::STATUS_VALIDATED
&& $object->type == Facture::TYPE_SITUATION && $object->type == Facture::TYPE_SITUATION
&& $user->rights->facture->creer && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) && $usercanunvalidate
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
) )
{ {
$outingError = 0; $outingError = 0;
@ -2388,7 +2399,7 @@ if (empty($reshook))
// add lines from objectlinked // add lines from objectlinked
elseif($action == 'import_lines_from_object' elseif($action == 'import_lines_from_object'
&& $user->rights->facture->creer && $usercancreate
&& $object->statut == Facture::STATUS_DRAFT && $object->statut == Facture::STATUS_DRAFT
&& ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION)) && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION))
{ {
@ -2481,7 +2492,7 @@ if (empty($reshook))
// Actions to build doc // Actions to build doc
$upload_dir = $conf->facture->dir_output; $upload_dir = $conf->facture->dir_output;
$permissioncreate=$user->rights->facture->creer; $permissioncreate=$usercancreate;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
@ -2508,7 +2519,7 @@ if (empty($reshook))
$action = 'edit_extras'; $action = 'edit_extras';
} }
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->facture->creer) { if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) {
if ($action == 'addcontact') { if ($action == 'addcontact') {
$result = $object->fetch($id); $result = $object->fetch($id);
@ -3474,11 +3485,10 @@ else if ($id > 0 || ! empty($ref))
$formquestion = array(); $formquestion = array();
// remove situation from cycle // remove situation from cycle
if ($object->statut == Facture::STATUS_VALIDATED if ($object->statut == Facture::STATUS_VALIDATED
&& $user->rights->facture->creer && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) && $usercanunvalidate
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
) )
{ {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $label, $text, 'confirm_situationout', $formquestion, "yes", 1);
@ -3689,8 +3699,8 @@ else if ($id > 0 || ! empty($ref))
$morehtmlref='<div class="refidno">'; $morehtmlref='<div class="refidno">';
// Ref customer // Ref customer
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1); $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1);
// Thirdparty // Thirdparty
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer');
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)'; if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
@ -3699,7 +3709,7 @@ else if ($id > 0 || ! empty($ref))
{ {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.='<br>'.$langs->trans('Project') . ' '; $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
if ($user->rights->facture->creer) if ($usercancreate)
{ {
if ($action != 'classify') if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
@ -3798,7 +3808,7 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateInvoice'); print $langs->trans('DateInvoice');
print '</td>'; print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editinvoicedate&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editinvoicedate&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
@ -3839,7 +3849,7 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort'); print $langs->trans('PaymentConditionsShort');
print '</td>'; print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $user->rights->facture->creer) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate)
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editconditions&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
@ -3860,7 +3870,7 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateMaxPayment'); print $langs->trans('DateMaxPayment');
print '</td>'; print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $user->rights->facture->creer) if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate)
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editpaymentterm&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editpaymentterm&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
@ -3884,7 +3894,7 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode'); print $langs->trans('PaymentMode');
print '</td>'; print '</td>';
if ($action != 'editmode' && $user->rights->facture->creer) if ($action != 'editmode' && $usercancreate)
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
@ -3907,15 +3917,12 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print fieldLabel('Currency','multicurrency_code'); print fieldLabel('Currency','multicurrency_code');
print '</td>'; print '</td>';
if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) if ($usercancreate && $action != 'editmulticurrencycode' && ! empty($object->brouillon))
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencycode&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($action == 'editmulticurrencycode') { $htmlname = (($usercancreate && $action == 'editmulticurrencycode')?'multicurrency_code':'none');
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, $htmlname);
} else {
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
}
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
@ -3923,7 +3930,7 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print fieldLabel('CurrencyRate','multicurrency_tx'); print fieldLabel('CurrencyRate','multicurrency_tx');
print '</td>'; print '</td>';
if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) if ($usercancreate && $action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency)
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmulticurrencyrate&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
@ -3931,7 +3938,7 @@ else if ($id > 0 || ! empty($ref))
if($action == 'actualizemulticurrencyrate') { if($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
} }
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, ($usercancreate?'multicurrency_tx':'none'), $object->multicurrency_code);
} else { } else {
$form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) { if($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
@ -3948,7 +3955,7 @@ else if ($id > 0 || ! empty($ref))
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">'; print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('BankAccount'); print $langs->trans('BankAccount');
print '<td>'; print '<td>';
if (($action != 'editbankaccount') && $user->rights->facture->creer) if (($action != 'editbankaccount') && $usercancreate)
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>'; print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
@ -3975,7 +3982,7 @@ else if ($id > 0 || ! empty($ref))
print '<table width="100%" class="nobordernopadding"><tr><td>'; print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel'); print $langs->trans('IncotermLabel');
print '<td><td align="right">'; print '<td><td align="right">';
if ($user->rights->facture->creer) print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; if ($usercancreate) print '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$object->id.'&action=editincoterm">'.img_edit().'</a>';
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr></table>'; print '</td></tr></table>';
print '</td>'; print '</td>';
@ -4049,7 +4056,7 @@ else if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('RevenueStamp'); print $langs->trans('RevenueStamp');
print '</td>'; print '</td>';
if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $user->rights->facture->creer) if ($action != 'editrevenuestamp' && ! empty($object->brouillon) && $usercancreate)
{ {
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editrevenuestamp&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . '</a></td>'; print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editrevenuestamp&amp;facid=' . $object->id . '">' . img_edit($langs->trans('SetRevenuStamp'), 1) . '</a></td>';
} }
@ -4525,7 +4532,7 @@ else if ($id > 0 || ! empty($ref))
if (! empty($conf->margin->enabled) && empty($user->societe_id)) if (! empty($conf->margin->enabled) && empty($user->societe_id))
{ {
print '<td align="right" class="margininfos" width="80">&nbsp;</td>'; print '<td align="right" class="margininfos" width="80">&nbsp;</td>';
if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $user->rights->margins->liretous) { if ((! empty($conf->global->DISPLAY_MARGIN_RATES) || ! empty($conf->global->DISPLAY_MARK_RATES)) && $usercanreadallmargin) {
print '<td align="right" class="margininfos" width="50">&nbsp;</td>'; print '<td align="right" class="margininfos" width="50">&nbsp;</td>';
} }
} }
@ -4576,7 +4583,7 @@ else if ($id > 0 || ! empty($ref))
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
// Form to add new line // Form to add new line
if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline' && ($object->is_first() || !$object->situation_cycle_ref)) if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline' && ($object->is_first() || !$object->situation_cycle_ref))
{ {
if ($action != 'editline' && $action != 'selectlines') if ($action != 'editline' && $action != 'selectlines')
{ {
@ -4617,8 +4624,7 @@ else if ($id > 0 || ! empty($ref))
{ {
if (! $objectidnext && $object->is_last_in_cycle()) if (! $objectidnext && $object->is_last_in_cycle())
{ {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) if ($usercanunvalidate)
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
{ {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
} else { } else {
@ -4645,7 +4651,7 @@ else if ($id > 0 || ! empty($ref))
|| ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id))
|| ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id))) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)))
&& ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data && ($object->statut == 2 || $object->statut == 3 || ($object->statut == 1 && $object->paye == 1)) // Condition ($object->statut == 1 && $object->paye == 1) should not happened but can be found due to corrupted data
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->invoice_advance->reopen))) // A paid invoice (partially or completely) && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || $usercanreopen)) // A paid invoice (partially or completely)
{ {
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
{ {
@ -4657,8 +4663,7 @@ else if ($id > 0 || ! empty($ref))
// Validate // Validate
if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) { if ($object->statut == Facture::STATUS_DRAFT && count($object->lines) > 0 && ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) && (! empty($conf->global->FACTURE_ENABLE_NEGATIVE) || $object->total_ttc >= 0)) || ($object->type == Facture::TYPE_CREDIT_NOTE && $object->total_ttc <= 0))) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) if ($usercanvalidate)
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)))
{ {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=valid">' . $langs->trans('Validate') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=valid">' . $langs->trans('Validate') . '</a></div>';
} }
@ -4669,7 +4674,7 @@ else if ($id > 0 || ! empty($ref))
if ($objectidnext) { if ($objectidnext) {
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('SendMail') . '</span></div>'; print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('SendMail') . '</span></div>';
} else { } else {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send) { if ($usercansend) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a></div>';
} else } else
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">' . $langs->trans('SendMail') . '</a></div>';
@ -4681,7 +4686,7 @@ else if ($id > 0 || ! empty($ref))
{ {
if ($resteapayer > 0) if ($resteapayer > 0)
{ {
if ($user->rights->prelevement->bons->creer) if ($usercancreatewithdrarequest)
{ {
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
{ {
@ -4702,7 +4707,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Create payment // Create payment
if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) { if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercanissuepayment) {
if ($objectidnext) { if ($objectidnext) {
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('DoPayment') . '</span></div>'; print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('DoPayment') . '</span></div>';
} else { } else {
@ -4717,7 +4722,7 @@ else if ($id > 0 || ! empty($ref))
// Reverse back money or convert to reduction // Reverse back money or convert to reduction
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD) { if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD) {
// For credit note only // For credit note only
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercanissuepayment)
{ {
if ($resteapayer == 0) if ($resteapayer == 0)
{ {
@ -4730,24 +4735,24 @@ else if ($id > 0 || ! empty($ref))
} }
// For standard invoice with excess received // For standard invoice with excess received
if ($object->type == Facture::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $user->rights->facture->creer && empty($discount->id)) if ($object->type == Facture::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id))
{ {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessReceivedToReduc').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertExcessReceivedToReduc').'</a></div>';
} }
// For credit note // For credit note
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->creer && $object->getSommePaiement() == 0) { if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate && $object->getSommePaiement() == 0) {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&amp;action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
} }
// For deposit invoice // For deposit invoice
if ($object->type == Facture::TYPE_DEPOSIT && $user->rights->facture->creer && $object->statut > 0 && empty($discount->id)) if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id))
{ {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'&amp;action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
} }
} }
// Classify paid // Classify paid
if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) if ($object->statut == 1 && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))
|| ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id))
) )
{ {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="'.$_SERVER['PHP_SELF'].'?facid='.$object->id.'&amp;action=paid">'.$langs->trans('ClassifyPaid').'</a></div>';
@ -4755,7 +4760,7 @@ else if ($id > 0 || ! empty($ref))
// Classify 'closed not completely paid' (possible si validee et pas encore classee payee) // Classify 'closed not completely paid' (possible si validee et pas encore classee payee)
if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $user->rights->facture->paiement) if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $usercanissuepayment)
{ {
if ($totalpaye > 0 || $totalcreditnotes > 0) if ($totalpaye > 0 || $totalcreditnotes > 0)
{ {
@ -4779,13 +4784,13 @@ else if ($id > 0 || ! empty($ref))
} }
// Clone // Clone
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $user->rights->facture->creer) if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $usercancreate)
{ {
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=clone&amp;object=invoice">' . $langs->trans("ToClone") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&amp;action=clone&amp;object=invoice">' . $langs->trans("ToClone") . '</a></div>';
} }
// Clone as predefined / Create template // Clone as predefined / Create template
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $user->rights->facture->creer) if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut == 0 && $usercancreate)
{ {
if (! $objectidnext && count($object->lines) > 0) if (! $objectidnext && count($object->lines) > 0)
{ {
@ -4794,7 +4799,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Create a credit note // Create a credit note
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $user->rights->facture->creer) if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $usercancreate)
{ {
if (! $objectidnext) if (! $objectidnext)
{ {
@ -4805,14 +4810,13 @@ else if ($id > 0 || ! empty($ref))
// For situation invoice with excess received // For situation invoice with excess received
if ($object->statut > Facture::STATUS_DRAFT if ($object->statut > Facture::STATUS_DRAFT
&& ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0
&& $user->rights->facture->creer && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE && $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE
) )
{ {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) if ($usercanunvalidate)
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->socid .'&amp;fac_avoir=' . $object->id . '&amp;invoiceAvoirWithLines=1&amp;action=create&amp;type=2'.($object->fk_project > 0 ? '&amp;projectid='.$object->fk_project : '').'">' . $langs->trans("CreateCreditNote") . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->socid .'&amp;fac_avoir=' . $object->id . '&amp;invoiceAvoirWithLines=1&amp;action=create&amp;type=2'.($object->fk_project > 0 ? '&amp;projectid='.$object->fk_project : '').'">' . $langs->trans("CreateCreditNote") . '</a></div>';
} else { } else {
@ -4823,12 +4827,11 @@ else if ($id > 0 || ! empty($ref))
// remove situation from cycle // remove situation from cycle
if ($object->statut > Facture::STATUS_DRAFT if ($object->statut > Facture::STATUS_DRAFT
&& $object->type == Facture::TYPE_SITUATION && $object->type == Facture::TYPE_SITUATION
&& $user->rights->facture->creer && $usercancreate
&& !$objectidnext && !$objectidnext
&& $object->situation_counter > 1 && $object->situation_counter > 1
&& $object->is_last_in_cycle() && $object->is_last_in_cycle()
&& ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->creer)) && $usercanunvalidate
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)))
) )
{ {
if(($object->total_ttc - $totalcreditnotes ) == 0 ) if(($object->total_ttc - $totalcreditnotes ) == 0 )
@ -4842,7 +4845,7 @@ else if ($id > 0 || ! empty($ref))
} }
// Create next situation invoice // Create next situation invoice
if ($user->rights->facture->creer && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) { if ($usercancreate && ($object->type == 5) && ($object->statut == 1 || $object->statut == 2)) {
if ($object->is_last_in_cycle() && $object->situation_final != 1) { if ($object->is_last_in_cycle() && $object->situation_final != 1) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create&amp;type=5&amp;origin=facture&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '" >' . $langs->trans('CreateNextSituationInvoice') . '</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create&amp;type=5&amp;origin=facture&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '" >' . $langs->trans('CreateNextSituationInvoice') . '</a></div>';
} else if (!$object->is_last_in_cycle()) { } else if (!$object->is_last_in_cycle()) {
@ -4854,7 +4857,7 @@ else if ($id > 0 || ! empty($ref))
// Delete // Delete
$isErasable = $object->is_erasable(); $isErasable = $object->is_erasable();
if ($user->rights->facture->supprimer || ($user->rights->facture->creer && $isErasable == 1)) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) if ($usercandelete || ($usercancreate && $isErasable == 1)) // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions)
{ {
//var_dump($isErasable); //var_dump($isErasable);
if ($isErasable == -4) { if ($isErasable == -4) {
@ -4901,8 +4904,8 @@ else if ($id > 0 || ! empty($ref))
$filename = dol_sanitizeFileName($object->ref); $filename = dol_sanitizeFileName($object->ref);
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref); $filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id; $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
$genallowed = $user->rights->facture->lire; $genallowed = $usercanread;
$delallowed = $user->rights->facture->creer; $delallowed = $usercancreate;
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
$somethingshown = $formfile->numoffiles; $somethingshown = $formfile->numoffiles;
@ -4911,7 +4914,7 @@ else if ($id > 0 || ! empty($ref))
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
$compatibleImportElementsList = false; $compatibleImportElementsList = false;
if($user->rights->facture->creer if($usercancreate
&& $object->statut == Facture::STATUS_DRAFT && $object->statut == Facture::STATUS_DRAFT
&& ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) ) && ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION) )
{ {

View File

@ -231,9 +231,10 @@ $disable_delete = 0;
// Bank account // Bank account
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
{ {
$bankline=new AccountLine($db);
if ($object->fk_account > 0) if ($object->fk_account > 0)
{ {
$bankline=new AccountLine($db);
$bankline->fetch($object->bank_line); $bankline->fetch($object->bank_line);
if ($bankline->rappro) if ($bankline->rappro)
{ {

View File

@ -1731,7 +1731,7 @@ function email_admin_prepare_head()
$h = 0; $h = 0;
$head = array(); $head = array();
if ($user->admin && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) if (! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates'))
{ {
$head[$h][0] = DOL_URL_ROOT."/admin/mails.php"; $head[$h][0] = DOL_URL_ROOT."/admin/mails.php";
$head[$h][1] = $langs->trans("OutGoingEmailSetup"); $head[$h][1] = $langs->trans("OutGoingEmailSetup");
@ -1752,7 +1752,7 @@ function email_admin_prepare_head()
$head[$h][2] = 'templates'; $head[$h][2] = 'templates';
$h++; $h++;
if ($conf->global->MAIN_FEATURES_LEVEL >= 1) if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && ! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates'))
{ {
$head[$h][0] = DOL_URL_ROOT."/admin/mails_senderprofile_list.php"; $head[$h][0] = DOL_URL_ROOT."/admin/mails_senderprofile_list.php";
$head[$h][1] = $langs->trans("EmailSenderProfiles"); $head[$h][1] = $langs->trans("EmailSenderProfiles");

View File

@ -2837,35 +2837,50 @@ function isValidPhone($phone)
* @param string $stringencoding Encoding of string * @param string $stringencoding Encoding of string
* @return int Length of string * @return int Length of string
*/ */
function dol_strlen($string,$stringencoding='UTF-8') function dol_strlen($string, $stringencoding='UTF-8')
{ {
if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding); if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding);
else return strlen($string); else return strlen($string);
} }
/** /**
* Make a substring. Works even in mbstring module is not enabled. * Make a substring. Works even if mbstring module is not enabled for better compatibility.
* *
* @param string $string String to scan * @param string $string String to scan
* @param string $start Start position * @param string $start Start position
* @param int $length Length * @param int $length Length (in nb of characters or nb of bytes depending on trunconbytes param)
* @param string $stringencoding Page code used for input string encoding * @param string $stringencoding Page code used for input string encoding
* @param int $trunconbytes 1=Length is max of bytes instead of max of characters
* @return string substring * @return string substring
*/ */
function dol_substr($string,$start,$length,$stringencoding='') function dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
{ {
global $langs; global $langs;
if (empty($stringencoding)) $stringencoding=$langs->charset_output; if (empty($stringencoding)) $stringencoding=$langs->charset_output;
$ret=''; $ret='';
if (function_exists('mb_substr')) if (empty($trunconbytes))
{ {
$ret=mb_substr($string,$start,$length,$stringencoding); if (function_exists('mb_substr'))
{
$ret=mb_substr($string, $start, $length, $stringencoding);
}
else
{
$ret=substr($string, $start, $length);
}
} }
else else
{ {
$ret=substr($string,$start,$length); if (function_exists('mb_strcut'))
{
$ret=mb_strcut($string, $start, $length, $stringencoding);
}
else
{
$ret=substr($string, $start, $length);
}
} }
return $ret; return $ret;
} }
@ -3063,7 +3078,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
* @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap * @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap
* @param string $stringencoding Tell what is source string encoding * @param string $stringencoding Tell what is source string encoding
* @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation. * @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation.
* @param int $display Trunc is use to display and can be changed for small screen. TODO Remove this param (must be dealt with CSS) * @param int $display Trunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
* @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise. * @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise.
*/ */
function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0) function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0)
@ -6782,26 +6797,27 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id
if ($key == '') return ''; if ($key == '') return '';
// Check in cache // Check in cache
if (isset($cache_codes[$tablename][$key])) // Can be defined to 0 or '' if (isset($cache_codes[$tablename][$key][$fieldid])) // Can be defined to 0 or ''
{ {
return $cache_codes[$tablename][$key]; // Found in cache return $cache_codes[$tablename][$key][$fieldid]; // Found in cache
} }
dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG);
$sql = "SELECT ".$fieldid." as valuetoget"; $sql = "SELECT ".$fieldid." as valuetoget";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'"; $sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'";
if (! empty($entityfilter)) if (! empty($entityfilter))
$sql.= " AND entity IN (" . getEntity($tablename) . ")"; $sql.= " AND entity IN (" . getEntity($tablename) . ")";
dol_syslog('dol_getIdFromCode', LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $cache_codes[$tablename][$key]=$obj->valuetoget; if ($obj) $cache_codes[$tablename][$key][$fieldid]=$obj->valuetoget;
else $cache_codes[$tablename][$key]=''; else $cache_codes[$tablename][$key][$fieldid]='';
$db->free($resql); $db->free($resql);
return $cache_codes[$tablename][$key]; return $cache_codes[$tablename][$key][$fieldid];
} }
else else
{ {
@ -6889,8 +6905,6 @@ function picto_from_langcode($codelang, $moreatt = '')
if (empty($codelang)) return ''; if (empty($codelang)) return '';
if (empty($codelang)) return '';
if ($codelang == 'auto') if ($codelang == 'auto')
{ {
return '<span class="fa fa-globe"></span>'; return '<span class="fa fa-globe"></span>';

View File

@ -990,7 +990,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
if ($bentityon) // only if entity enable if ($bentityon) // only if entity enable
$sql.= " AND entity IN (".getEntity($sharetable).")"; $sql.= " AND entity IN (".getEntity($sharetable).")";
else if (! empty($forceentity)) else if (! empty($forceentity))
$sql.= " AND entity = ".(int) $forceentity; $sql.= " AND entity IN (".$forceentity.")";
if ($where) $sql.=$where; if ($where) $sql.=$where;
if ($sqlwhere) $sql.=' AND '.$sqlwhere; if ($sqlwhere) $sql.=' AND '.$sqlwhere;
@ -1039,7 +1039,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
if ($bentityon) // only if entity enable if ($bentityon) // only if entity enable
$sql.= " AND entity IN (".getEntity($sharetable).")"; $sql.= " AND entity IN (".getEntity($sharetable).")";
else if (! empty($forceentity)) else if (! empty($forceentity))
$sql.= " AND entity = ".(int) $forceentity; $sql.= " AND entity IN (".$forceentity.")";
if ($where) $sql.=$where; if ($where) $sql.=$where;
if ($sqlwhere) $sql.=' AND '.$sqlwhere; if ($sqlwhere) $sql.=' AND '.$sqlwhere;
@ -1095,7 +1095,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
if ($bentityon) // only if entity enable if ($bentityon) // only if entity enable
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
else if (! empty($forceentity)) else if (! empty($forceentity))
$sql.= " AND entity = ".(int) $forceentity; $sql.= " AND entity IN (".$forceentity.")";
if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask
if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask
$maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')";

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -145,19 +145,19 @@ class mod_facture_mars extends ModeleNumRefFactures
* Return next value not used or last value used * Return next value not used or last value used
* *
* @param Societe $objsoc Object third party * @param Societe $objsoc Object third party
* @param Facture $facture Object invoice * @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value * @param string $mode 'next' for next value or 'last' for last value
* @return string Value * @return string Value
*/ */
function getNextValue($objsoc,$facture,$mode='next') function getNextValue($objsoc, $invoice, $mode='next')
{ {
global $db; global $db;
$prefix=$this->prefixinvoice; $prefix=$this->prefixinvoice;
if ($facture->type == 1) $prefix=$this->prefixreplacement; if ($invoice->type == 1) $prefix=$this->prefixreplacement;
else if ($facture->type == 2) $prefix=$this->prefixcreditnote; else if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit; else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice; else $prefix=$this->prefixinvoice;
// D'abord on recupere la valeur max // D'abord on recupere la valeur max
@ -165,7 +165,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$resql=$db->query($sql); $resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -189,7 +189,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref"; $sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
$sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
@ -204,7 +204,7 @@ class mod_facture_mars extends ModeleNumRefFactures
} }
else if ($mode == 'next') else if ($mode == 'next')
{ {
$date=$facture->date; // This is invoice date (not creation date) $date=$invoice->date; // This is invoice date (not creation date)
$yymm = strftime("%y%m",$date); $yymm = strftime("%y%m",$date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is

View File

@ -131,19 +131,19 @@ class mod_facture_mercure extends ModeleNumRefFactures
* Return next value * Return next value
* *
* @param Societe $objsoc Object third party * @param Societe $objsoc Object third party
* @param Facture $facture Object invoice * @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value * @param string $mode 'next' for next value or 'last' for last value
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc,$facture,$mode='next') function getNextValue($objsoc, $invoice, $mode='next')
{ {
global $db,$conf; global $db,$conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
// Get Mask value // Get Mask value
$mask = ''; $mask = '';
if (is_object($facture) && $facture->type == 1) if (is_object($invoice) && $invoice->type == 1)
{ {
$mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT; $mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
if (! $mask) if (! $mask)
@ -151,8 +151,8 @@ class mod_facture_mercure extends ModeleNumRefFactures
$mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
} }
} }
else if (is_object($facture) && $facture->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT; else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
else if (is_object($facture) && $facture->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT; else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE; else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
if (! $mask) if (! $mask)
{ {
@ -160,14 +160,17 @@ class mod_facture_mercure extends ModeleNumRefFactures
return 0; return 0;
} }
$where=''; $where='';
//if ($facture->type == 2) $where.= " AND type = 2"; //if ($facture->type == 2) $where.= " AND type = 2";
//else $where.=" AND type != 2"; //else $where.=" AND type != 2";
$numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$facture->date,$mode); // Get entities
if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal; $entity = getEntity('invoicenumber', 1, $invoice);
return $numFinal; $numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$invoice->date,$mode,false,null,$entity);
if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal;
return $numFinal;
} }

View File

@ -163,16 +163,16 @@ class mod_facture_terre extends ModeleNumRefFactures
* Return next value not used or last value used * Return next value not used or last value used
* *
* @param Societe $objsoc Object third party * @param Societe $objsoc Object third party
* @param Facture $facture Object invoice * @param Facture $invoice Object invoice
* @param string $mode 'next' for next value or 'last' for last value * @param string $mode 'next' for next value or 'last' for last value
* @return string Value * @return string Value
*/ */
function getNextValue($objsoc,$facture,$mode='next') function getNextValue($objsoc, $invoice, $mode='next')
{ {
global $db; global $db;
if ($facture->type == 2) $prefix=$this->prefixcreditnote; if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit; else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
else $prefix=$this->prefixinvoice; else $prefix=$this->prefixinvoice;
// D'abord on recupere la valeur max // D'abord on recupere la valeur max
@ -180,7 +180,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
$resql=$db->query($sql); $resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -204,7 +204,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref"; $sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
$sql.= " AND entity IN (".getEntity('invoicenumber').")"; $sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);
@ -219,7 +219,7 @@ class mod_facture_terre extends ModeleNumRefFactures
} }
else if ($mode == 'next') else if ($mode == 'next')
{ {
$date=$facture->date; // This is invoice date (not creation date) $date=$invoice->date; // This is invoice date (not creation date)
$yymm = strftime("%y%m",$date); $yymm = strftime("%y%m",$date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is

View File

@ -122,7 +122,7 @@ class mod_project_simple extends ModeleNumRefProjects
* @param Project $project Object project * @param Project $project Object project
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc,$project) function getNextValue($objsoc, $project)
{ {
global $db,$conf; global $db,$conf;
@ -167,9 +167,9 @@ class mod_project_simple extends ModeleNumRefProjects
* @param Project $project Object project * @param Project $project Object project
* @return string Next not used reference * @return string Next not used reference
*/ */
function project_get_num($objsoc=0,$project='') function project_get_num($objsoc=0, $project='')
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc,$project); return $this->getNextValue($objsoc, $project);
} }
} }

View File

@ -123,7 +123,7 @@ class mod_project_universal extends ModeleNumRefProjects
* @param Project $project Object project * @param Project $project Object project
* @return string Value if OK, 0 if KO * @return string Value if OK, 0 if KO
*/ */
function getNextValue($objsoc,$project) function getNextValue($objsoc, $project)
{ {
global $db,$conf; global $db,$conf;
@ -139,7 +139,7 @@ class mod_project_universal extends ModeleNumRefProjects
} }
$date=empty($project->date_c)?dol_now():$project->date_c; $date=empty($project->date_c)?dol_now():$project->date_c;
$numFinal=get_next_value($db,$mask,'projet','ref','',$objsoc->code_client,$date); $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);
return $numFinal; return $numFinal;
} }
@ -153,9 +153,9 @@ class mod_project_universal extends ModeleNumRefProjects
* @param Project $project Object project * @param Project $project Object project
* @return string Next not used reference * @return string Next not used reference
*/ */
function project_get_num($objsoc=0,$project='') function project_get_num($objsoc=0, $project='')
{ {
// phpcs:enable // phpcs:enable
return $this->getNextValue($objsoc,$project); return $this->getNextValue($objsoc, $project);
} }
} }

View File

@ -128,15 +128,12 @@ class mod_propale_marbre extends ModeleNumRefPropales
{ {
global $db,$conf; global $db,$conf;
// Use object entity ID
$entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity);
// D'abord on recupere la valeur max // D'abord on recupere la valeur max
$posindice=8; $posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$entity; $sql.= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)

View File

@ -134,14 +134,8 @@ class mod_propale_saphir extends ModeleNumRefPropales
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
$constant = 'PROPALE_SAPHIR_MASK_'.$propal->entity;
// On defini critere recherche compteur // On defini critere recherche compteur
if (! empty($conf->global->$constant)) { $mask = $conf->global->PROPALE_SAPHIR_MASK;
$mask = $conf->global->$constant; // for multicompany proposal sharing
} else {
$mask = $conf->global->PROPALE_SAPHIR_MASK;
}
if (! $mask) if (! $mask)
{ {
@ -149,8 +143,8 @@ class mod_propale_saphir extends ModeleNumRefPropales
return 0; return 0;
} }
// Use object entity ID // Get entities
$entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity); $entity = getEntity('proposalnumber', 1, $propal);
$date = $propal->date; $date = $propal->date;

View File

@ -10,7 +10,7 @@ if (empty($conf) || ! is_object($conf))
if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element; if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
// Loop to complete the sql search criterias from extrafields // Loop to complete the sql search criterias from extrafields
if (! empty($extrafieldsobjectkey) && ! empty($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ... if (! empty($extrafieldsobjectkey) && ! empty($search_array_options) && is_array($search_array_options)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
{ {
foreach ($search_array_options as $key => $val) foreach ($search_array_options as $key => $val)
{ {

View File

@ -45,7 +45,7 @@ class EmailCollector extends CommonObject
/** /**
* @var int Does emailcollector support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int Does emailcollector support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/ */
public $ismultientitymanaged = 0; public $ismultientitymanaged = 1;
/** /**
* @var int Does emailcollector support extrafields ? 0=No, 1=Yes * @var int Does emailcollector support extrafields ? 0=No, 1=Yes
*/ */
@ -697,6 +697,94 @@ class EmailCollector extends CommonObject
return $nberror; return $nberror;
} }
/**
* overwitePropertiesOfObject
*
* @return int 0=OK, Nb of error if error
*/
/**
* overwitePropertiesOfObject
*
* @param object $object Current object
* @param string $actionparam Action parameters
* @param string $messagetext Body
* @param string $subject Subject
* @return int 0=OK, Nb of error if error
*/
private function overwritePropertiesOfObject(&$object, $actionparam, $messagetext, $subject)
{
$errorforthisaction = 0;
// Overwrite values with values extracted from source email
// $this->actionparam = 'opportunity_status=123;abc=REGEX:BODY:....'
$arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '=');
foreach($arrayvaluetouse as $propertytooverwrite => $valueforproperty)
{
$tmpclass=''; $tmpproperty='';
$tmparray=explode('.', $propertytooverwrite);
if (count($tmparray) == 2)
{
$tmpclass=$tmparray[0];
$tmpproperty=$tmparray[1];
}
else
{
$tmpproperty=$tmparray[0];
}
if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object
if (property_exists($object, $tmpproperty))
{
$sourcestring='';
$sourcefield='';
$regexstring='';
$transformationstring='';
$regforregex=array();
if (preg_match('/^REGEX:([a-zA-Z0-9]+):(.*):([^:])$/', $valueforproperty, $regforregex))
{
$sourcefield=$regforregex[0];
$regexstring=$regforregex[1];
$transofrmationstring=$regforregex[2];
}
elseif (preg_match('/^REGEX:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex))
{
$sourcefield=$regforregex[0];
$regexstring=$regforregex[1];
}
if (! empty($sourcestring) && ! empty($regexstring))
{
if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext;
elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject;
$regforval=array();
if (preg_match('/'.preg_quote($regexstring, '/').'/', $sourcestring, $regforval))
{
// Overwrite param $tmpproperty
$object->$tmpproperty = $regforval[0];
}
else
{
// Nothing can be done for this param
}
}
elseif (preg_match('/^VALUE:(.*)$/', $valueforproperty, $reg))
{
$object->$tmpproperty = $reg[0];
}
else
{
$errorforthisaction++;
$this->error = 'Bad syntax for description of action parameters: '.$actionparam;
$this->errors[] = $this->error;
}
}
}
return $errorforthisaction;
}
/** /**
* Execute collect for current collector loaded previously with fetch. * Execute collect for current collector loaded previously with fetch.
* *
@ -708,14 +796,16 @@ class EmailCollector extends CommonObject
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG); dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG);
$langs->loadLangs(array("project", "companies", "errors"));
$error = 0; $error = 0;
$this->output = ''; $this->output = '';
$this->error=''; $this->error='';
dol_syslog(__METHOD__, LOG_DEBUG);
$now = dol_now(); $now = dol_now();
if (empty($this->host)) if (empty($this->host))
@ -778,13 +868,12 @@ class EmailCollector extends CommonObject
if ($this->datelastresult && $this->codelastresult == 'OK') $fromdate = $this->datelastresult; if ($this->datelastresult && $this->codelastresult == 'OK') $fromdate = $this->datelastresult;
if ($fromdate > 0) $search.=($search?' ':'').'SINCE '.dol_print_date($fromdate - 1,'dayhourrfc'); if ($fromdate > 0) $search.=($search?' ':'').'SINCE '.dol_print_date($fromdate - 1,'dayhourrfc');
} }
dol_syslog("search string = ".$search); dol_syslog("IMAP search string = ".$search);
//var_dump($search); //var_dump($search);
$nbemailprocessed=0; $nbactiondone=0; $nbemailprocessed=0;
$projectstatic=new Project($this->db); $nbemailok=0;
$thirdpartystatic=new Societe($this->db); $nbactiondone=0;
$contactstatic=new Contact($this->db);
// Scan IMAP inbox // Scan IMAP inbox
$arrayofemail= imap_search($connection, $search); $arrayofemail= imap_search($connection, $search);
@ -797,7 +886,16 @@ class EmailCollector extends CommonObject
{ {
if ($nbemailprocessed > 100) break; // Do not process more than 100 email per launch if ($nbemailprocessed > 100) break; // Do not process more than 100 email per launch
$thirdpartystatic=new Societe($this->db);
$contactstatic=new Contact($this->db);
$projectstatic=new Project($this->db);
$nbactiondoneforemail = 0;
$errorforemail = 0;
$errorforactions = 0; $errorforactions = 0;
$thirdpartyfoundby = '';
$contactfoundby = '';
$projectfoundby = '';
$this->db->begin(); $this->db->begin();
@ -830,8 +928,9 @@ class EmailCollector extends CommonObject
$sendtocc=$overview[0]->cc; $sendtocc=$overview[0]->cc;
$sendtobcc=$overview[0]->bcc; $sendtobcc=$overview[0]->bcc;
$date=$overview[0]->udate; $date=$overview[0]->udate;
$msgid=$overview[0]->message_id; $msgid=str_replace(array('<','>'), '', $overview[0]->message_id);
$subject=$overview[0]->subject; $subject=$overview[0]->subject;
//var_dump($msgid);exit;
$reg=array(); $reg=array();
if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg))
@ -845,12 +944,16 @@ class EmailCollector extends CommonObject
$fromtext=''; $fromtext='';
} }
$fk_element_id = 0; $fk_element_type = ''; $fk_element_id = 0; $fk_element_type = '';
$contactid = 0; $thirdpartyid = 0; $projectid = 0; $contactid = 0; $thirdpartyid = 0; $projectid = 0;
// Analyze TrackId // Analyze TrackId
$trackid = '';
$reg=array(); $reg=array();
if (! empty($headers['X-Dolibarr-TrackId']) && preg_match('/:\s*([a-z]+)([0-9]+)$/', $headers['X-Dolibarr-TrackId'], $reg)) if (! empty($headers['X-Dolibarr-TrackId']) && preg_match('/:\s*([a-z]+)([0-9]+)$/', $headers['X-Dolibarr-TrackId'], $reg))
{ {
$trackid = $reg[0].$reg[1];
$objectid = 0; $objectid = 0;
$objectemail = null; $objectemail = null;
if ($reg[0] == 'inv') if ($reg[0] == 'inv')
@ -888,50 +991,93 @@ class EmailCollector extends CommonObject
if ($fk_element_type == 'facture') $fk_element_type = 'invoice'; if ($fk_element_type == 'facture') $fk_element_type = 'invoice';
$thirdpartyid = $objectemail->fk_soc; $thirdpartyid = $objectemail->fk_soc;
$contactid = $objectemail->fk_socpeople;
$projectid = isset($objectemail->fk_project)?$objectemail->fk_project:$objectemail->fk_projet; $projectid = isset($objectemail->fk_project)?$objectemail->fk_project:$objectemail->fk_projet;
} }
// Project
if ($projectid > 0)
{
$result = $projectstatic->fetch($projectid);
if ($result <= 0) $projectstatic->id = 0;
else
{
$projectid = $projectstatic->id;
$projectfoundby = 'trackid ('.$trackid.')';
if (empty($contactid)) $contactid = $projectstatic->fk_contact;
if (empty($thirdpartyid)) $thirdpartyid = $projectstatic->fk_soc;
}
}
// Contact
if ($contactid > 0)
{
$result = $contactstatic->fetch($contactid);
if ($result <= 0) $contactstatic->id = 0;
else
{
$contactid = $contactstatic->id;
$contactfoundby = 'trackid ('.$trackid.')';
if (empty($thirdpartyid)) $thirdpartyid = $contactstatic->fk_soc;
}
}
// Thirdparty
if ($thirdpartyid > 0)
{
$result = $thirdpartystatic->fetch($thirdpartyid);
if ($result <= 0) $thirdpartystatic->id = 0;
else
{
$thirdpartyid = $thirdpartystatic->id;
$thirdpartyfoundby = 'trackid ('.$trackid.')';
}
}
} }
// Project if (empty($contactid)) // Try to find contact using email
$projectstatic->id=0;
if ($projectid > 0)
{ {
$result = $projectstatic->fetch($projectid); $result = $contactstatic->fetch(0, null, '', $from);
if ($result <= 0) $projectstatic->id = 0; if ($result > 0)
} {
// Contact $contactid = $contactstatic->id;
$contactstatic->id=0; $contactfoundby = 'email of contact ('.$from.')';
if ($contactid > 0) if ($contactstatic->fk_soc > 0)
{ {
$result = $contactstatic->fetch($contactid); $result = $thirdpartystatic->fetch($contactstatic->fk_soc);
if ($result <= 0) $contactstatic->id = 0; if ($result > 0)
} {
else // Try to find contact using email $thirdpartyid = $thirdpartystatic->id;
{ $thirdpartyfoundby = 'email of contact ('.$from.')';
$contactstatic->fetch(0, null, '', $from); }
} }
// Thirdparty }
$thirdpartystatic->id=0;
if ($thirdpartyid > 0)
{
$result = $thirdpartystatic->fetch($thirdpartyid);
if ($result <= 0) $thirdpartystatic->id = 0;
}
else // Try to find thirdparty using email
{
$thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from);
} }
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; if (empty($thirdpartyid)) // Try to find thirdparty using email
{
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from);
if ($result > 0) $thirdpartyfoundby = 'email ('.$from.')';
}
// Do operationss
// Do operations
foreach($this->actions as $operation) foreach($this->actions as $operation)
{ {
if ($errorforactions) break; if ($errorforactions) break;
if (empty($operation['status'])) continue; if (empty($operation['status'])) continue;
// Make Operation // Make Operation
if ($operation['type'] == 'recordevent')
// Search and create thirdparty
if ($operation['type'] == 'searchandcreatethirdparty')
{
}
// Create event
elseif ($operation['type'] == 'recordevent')
{ {
$actioncode = 'EMAIL_IN'; $actioncode = 'EMAIL_IN';
@ -942,7 +1088,7 @@ class EmailCollector extends CommonObject
$actioncomm->code = 'AC_'.$actioncode; $actioncomm->code = 'AC_'.$actioncode;
$actioncomm->label = $langs->trans("EmailReceived").' - '.$langs->trans("From").' '.$from; $actioncomm->label = $langs->trans("EmailReceived").' - '.$langs->trans("From").' '.$from;
$actioncomm->note = $messagetext; $actioncomm->note = $messagetext;
$actioncomm->fk_project = 0; $actioncomm->fk_project = $projectstatic->id;
$actioncomm->datep = $date; $actioncomm->datep = $date;
$actioncomm->datef = $date; $actioncomm->datef = $date;
$actioncomm->percentage = -1; // Not applicable $actioncomm->percentage = -1; // Not applicable
@ -950,7 +1096,7 @@ class EmailCollector extends CommonObject
$actioncomm->contactid = $contactstatic->id; $actioncomm->contactid = $contactstatic->id;
$actioncomm->authorid = $user->id; // User saving action $actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action $actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is en email (content should be added into note) // Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $msgid; $actioncomm->email_msgid = $msgid;
$actioncomm->email_from = $fromstring; $actioncomm->email_from = $fromstring;
$actioncomm->email_sender= $sender; $actioncomm->email_sender= $sender;
@ -960,63 +1106,169 @@ class EmailCollector extends CommonObject
$actioncomm->email_subject = $subject; $actioncomm->email_subject = $subject;
$actioncomm->errors_to = ''; $actioncomm->errors_to = '';
$object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending to have it defined here
$object->email_from = $from;
$object->email_subject = $subject;
$object->email_to = $to;
$object->email_tocc = $sendtocc;
$object->email_tobcc = $sendtobcc;
$object->email_subject = $subject;
$actioncomm->fk_element = $fk_element_id; $actioncomm->fk_element = $fk_element_id;
$actioncomm->elementtype = $fk_element_type; $actioncomm->elementtype = $fk_element_type;
//$actioncomm->extraparams = $extraparams; //$actioncomm->extraparams = $extraparams;
$result = $actioncomm->create($user);
if ($result <= 0) // Overwrite values with values extracted from source email
$errorforthisaction = $this->overwritePropertiesOfObject($actioncommn, $operation['actionparam'], $messagetext, $subject);
if ($errorforthisaction)
{ {
$errorforactions++; $errorforactions++;
$this->errors = $actioncomm->errors; }
else
{
$result = $actioncomm->create($user);
if ($result <= 0)
{
$errorforactions++;
$this->errors = $actioncomm->errors;
}
} }
} }
elseif ($operation['type'] == 'aaa') // Create event
elseif ($operation['type'] == 'project')
{ {
$note_private = $langs->trans("ProjectCreatedByEmailCollector", $msgid);
$projecttocreate = new Project($this->db);
if ($thirdpartystatic->id > 0)
{
$projecttocreate->fk_soc = $thirdpartystatic->id;
if ($thirdpartyfoundby) $note_private .= ' - Third party found from '.$thirdpartyfoundby;
}
if ($contactstatic->id > 0)
{
$projecttocreate->contact_id = $contactstatic->id;
if ($contactfoundby) $note_private .= ' - Contact/address found from '.$contactfoundby;
}
$id_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'rowid');
$percent_opp_status = dol_getIdFromCode($this->db, 'PROSP', 'c_lead_status', 'code', 'percent');
$projecttocreate->title = $subject;
$projecttocreate->date_start = $now;
$projecttocreate->opp_status = $id_opp_status;
$projecttocreate->opp_percent = $percent_opp_status;
$projecttocreate->description = ($note_private?$note_private."\n":'').$messagetext;
$projecttocreate->note_private = $note_private;
$projecttocreate->entity = $conf->entity;
// Get next project Ref
$defaultref='';
$modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
// Search template files
$file=''; $classname=''; $filefound=0;
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
$file=dol_buildpath($reldir."core/modules/project/".$modele.'.php',0);
if (file_exists($file))
{
$filefound=1;
$classname = $modele;
break;
}
}
if ($filefound)
{
$result=dol_include_once($reldir."core/modules/project/".$modele.'.php');
$modProject = new $classname;
$defaultref = $modProject->getNextValue(($thirdpartystatic->id > 0 ? $thirdpartystatic : null), $projecttocreate);
}
$projecttocreate->ref = $defaultref;
// Overwrite values with values extracted from source email
$errorforthisaction = $this->overwritePropertiesOfObject($projecttocreate, $operation['actionparam'], $messagetext, $subject);
if ($errorforthisaction)
{
$errorforactions++;
}
else
{
if (is_numeric($projecttocreate->ref) && $projecttocreate->ref <= 0)
{
$errorforactions++;
$this->error = 'Failed to create project: Can\'t get a valid value for project Ref';
}
else
{
// Create project
$result = $projecttocreate->create($user);
if ($result <= 0)
{
$errorforactions++;
$this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error);
$this->errors = $projecttocreate->errors;
}
}
}
} }
if (! $errorforactions) if (! $errorforactions)
{ {
$nbactiondone++; $nbactiondoneforemail++;
} }
} }
// Move email // Error for email or not ?
if (! $errorforactions && $targetdir) if (! $errorforactions)
{ {
dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG); if ($targetdir)
$res = imap_mail_move($connection, $imapemail, $targetdir, 0); {
if ($res == false) { dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG);
$error++; $res = imap_mail_move($connection, $imapemail, $targetdir, 0);
$this->error = imap_last_error(); if ($res == false) {
dol_syslog(imap_last_error()); $errorforemail++;
$this->error = imap_last_error();
$this->errors[] = $this->error;
dol_syslog(imap_last_error());
}
} }
else
{
dol_syslog("EmailCollector::doCollectOneCollector message ".$imapemail." to ".$connectstringtarget." was set to read", LOG_DEBUG);
}
}
else
{
$errorforemail++;
}
if (! $errorforemail)
{
$nbactiondone += $nbactiondoneforemail;
$nbemailok++;
$this->db->commit();
}
else
{
$error++;
$this->db->rollback();
} }
$nbemailprocessed++; $nbemailprocessed++;
unset($objectemail); unset($objectemail);
unset($projectstatic);
$this->db->commit(); unset($thirdpartystatic);
unset($contactstatic);
} }
$this->output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbactiondone); $output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone);
} }
else else
{ {
$this->output=$langs->trans('NoNewEmailToProcess'); $output=$langs->trans('NoNewEmailToProcess');
} }
imap_expunge($connection); // To validate any move imap_expunge($connection); // To validate any move
@ -1024,7 +1276,8 @@ class EmailCollector extends CommonObject
imap_close($connection); imap_close($connection);
$this->datelastresult = $now; $this->datelastresult = $now;
$this->lastresult = $this->output; $this->lastresult = $output;
if (! empty($this->errors)) $this->lastresult.= " - ".join(" - ", $this->errors);
$this->codelastresult = ($error ? 'KO' : 'OK'); $this->codelastresult = ($error ? 'KO' : 'OK');
$this->update($user); $this->update($user);

View File

@ -159,6 +159,17 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '506', 'KG
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '507', 'Ltd. - Limited Company'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '507', 'Ltd. - Limited Company');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '508', 'OHG - Offene Handelsgesellschaft'); insert into llx_c_forme_juridique (fk_pays, code, libelle) values (5, '508', 'OHG - Offene Handelsgesellschaft');
-- Denmark
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8001', 'Aktieselvskab A/S');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8002', 'Anparts Selvskab ApS');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8003', 'Personlig ejet selvskab');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8004', 'Iværksætterselvskab IVS');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8005', 'Interessentskab I/S');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8006', 'Holdingselskab');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8007', 'Selskab Med Begrænset Hæftelse SMBA');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8008', 'Kommanditselskab K/S');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8009', 'SPE-selskab');
-- Greece -- Greece
INSERT INTO llx_c_forme_juridique (code,fk_pays,libelle,isvatexempted,active) VALUES ('10201',102,'Ατομική επιχείρηση',0,1); INSERT INTO llx_c_forme_juridique (code,fk_pays,libelle,isvatexempted,active) VALUES ('10201',102,'Ατομική επιχείρηση',0,1);
INSERT INTO llx_c_forme_juridique (code,fk_pays,libelle,isvatexempted,active) VALUES ('10202',102,'Εταιρική επιχείρηση',0,1); INSERT INTO llx_c_forme_juridique (code,fk_pays,libelle,isvatexempted,active) VALUES ('10202',102,'Εταιρική επιχείρηση',0,1);
@ -314,3 +325,4 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178,
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17803', 'Sociedad de Responsabilidad Limitada', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17803', 'Sociedad de Responsabilidad Limitada', 1);
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17804', 'Sociedad Civil', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17804', 'Sociedad Civil', 1);
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17805', 'Sociedad Anónima', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17805', 'Sociedad Anónima', 1);

View File

@ -55,7 +55,7 @@ ALTER TABLE llx_product_fournisseur_price ADD COLUMN desc_fourn text after ref_f
ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment; ALTER TABLE llx_user ADD COLUMN dateemploymentend date after dateemployment;
ALTER TABLE llx_stock_mouvement ADD COLUMN fk_project integer; ALTER TABLE llx_stock_mouvement ADD COLUMN fk_project integer;
Alter tABLE llx_c_action_trigger MODIFY COLUMN elementtype varchar(32) ALTER TABLE llx_c_action_trigger MODIFY COLUMN elementtype varchar(32);
ALTER TABLE llx_c_field_list ADD COLUMN visible tinyint DEFAULT 1 NOT NULL AFTER search; ALTER TABLE llx_c_field_list ADD COLUMN visible tinyint DEFAULT 1 NOT NULL AFTER search;
@ -72,6 +72,16 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203);
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8001', 'Aktieselvskab A/S');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8002', 'Anparts Selvskab ApS');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8003', 'Personlig ejet selvskab');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8004', 'Iværksætterselvskab IVS');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8005', 'Interessentskab I/S');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8006', 'Holdingselskab');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8007', 'Selskab Med Begrænset Hæftelse SMBA');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8008', 'Kommanditselskab K/S');
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle) VALUES (80, '8009', 'SPE-selskab');
ALTER TABLE llx_payment_salary ADD COLUMN ref varchar(30) NULL after rowid; ALTER TABLE llx_payment_salary ADD COLUMN ref varchar(30) NULL after rowid;
ALTER TABLE llx_payment_salary ADD COLUMN fk_projet integer DEFAULT NULL after amount; ALTER TABLE llx_payment_salary ADD COLUMN fk_projet integer DEFAULT NULL after amount;

View File

@ -1833,7 +1833,7 @@ EmailCollectorConfirmCollectTitle=Email collect confirmation
EmailCollectorConfirmCollect=Do you want to run the collect for this collector now ? EmailCollectorConfirmCollect=Do you want to run the collect for this collector now ?
NoNewEmailToProcess=No new email (matching filters) to process NoNewEmailToProcess=No new email (matching filters) to process
NothingProcessed=Nothing done NothingProcessed=Nothing done
XEmailsDoneYActionsDone=%s emails analyzed, %s record/actions done by collector XEmailsDoneYActionsDone=%s emails analyzed, %s emails successfuly processed (for %s record/actions done) by collector
RecordEvent=Record event RecordEvent=Record event
CreateLeadAndThirdParty=Create lead (and thirdparty if necessary) CreateLeadAndThirdParty=Create lead (and thirdparty if necessary)
CodeLastResult=Result code of last collect CodeLastResult=Result code of last collect

View File

@ -431,4 +431,4 @@ SaleRepresentativeLogin=Login of sales representative
SaleRepresentativeFirstname=First name of sales representative SaleRepresentativeFirstname=First name of sales representative
SaleRepresentativeLastname=Last name of sales representative SaleRepresentativeLastname=Last name of sales representative
ErrorThirdpartiesMerge=There was an error when deleting the third parties. Please check the log. Changes have been reverted. ErrorThirdpartiesMerge=There was an error when deleting the third parties. Please check the log. Changes have been reverted.
NewCustomerSupplierCodeProposed=New customer or vendor code suggested on duplicate code NewCustomerSupplierCodeProposed=Customer or vendor code already used, a new code is suggested

View File

@ -244,6 +244,9 @@ YourPasswordHasBeenReset=Your password has been reset successfully
ApplicantIpAddress=IP address of applicant ApplicantIpAddress=IP address of applicant
SMSSentTo=SMS sent to %s SMSSentTo=SMS sent to %s
MissingIds=Missing ids MissingIds=Missing ids
ThirdPartyCreatedByEmailCollector=Third party created by email collector from email ID %s
ContactCreatedByEmailCollector=Contact/address created by email collector from email ID %s
ProjectCreatedByEmailCollector=Project created by email collector from email ID %s
##### Export ##### ##### Export #####
ExportsArea=Exports area ExportsArea=Exports area

View File

@ -184,6 +184,7 @@ ProjectsWithThisUserAsContact=Projects with this user as contact
TasksWithThisUserAsContact=Tasks assigned to this user TasksWithThisUserAsContact=Tasks assigned to this user
ResourceNotAssignedToProject=Not assigned to project ResourceNotAssignedToProject=Not assigned to project
ResourceNotAssignedToTheTask=Not assigned to the task ResourceNotAssignedToTheTask=Not assigned to the task
NoUserAssignedToTheProject=No users assigned to this project
TimeSpentBy=Time spent by TimeSpentBy=Time spent by
TasksAssignedTo=Tasks assigned to TasksAssignedTo=Tasks assigned to
AssignTaskToMe=Assign task to me AssignTaskToMe=Assign task to me
@ -232,3 +233,4 @@ DontHaveTheValidateStatus=The project %s must be open to be closed
RecordsClosed=%s project(s) closed RecordsClosed=%s project(s) closed
SendProjectRef=Information project %s SendProjectRef=Information project %s
ModuleSalaryToDefineHourlyRateMustBeEnabled=Module 'Payment of employee wages' must be enabled to define employee hourly rate to have time spent valorized ModuleSalaryToDefineHourlyRateMustBeEnabled=Module 'Payment of employee wages' must be enabled to define employee hourly rate to have time spent valorized
NewTaskRefSuggested=Task ref already used, a new task ref is suggested

View File

@ -179,6 +179,10 @@ class Project extends CommonObject
$now=dol_now(); $now=dol_now();
// Clean parameters
$this->note_private = dol_substr($this->note_private, 0, 65535);
$this->note_public = dol_substr($this->note_public, 0, 65535);
// Check parameters // Check parameters
if (!trim($this->ref)) if (!trim($this->ref))
{ {
@ -193,6 +197,7 @@ class Project extends CommonObject
return -1; return -1;
} }
// Create project
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet ("; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet (";
@ -211,6 +216,8 @@ class Project extends CommonObject
$sql.= ", opp_amount"; $sql.= ", opp_amount";
$sql.= ", budget_amount"; $sql.= ", budget_amount";
$sql.= ", bill_time"; $sql.= ", bill_time";
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ", entity"; $sql.= ", entity";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'" . $this->db->escape($this->ref) . "'"; $sql.= "'" . $this->db->escape($this->ref) . "'";
@ -228,6 +235,8 @@ class Project extends CommonObject
$sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null'); $sql.= ", " . (strcmp($this->opp_amount,'') ? price2num($this->opp_amount) : 'null');
$sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null'); $sql.= ", " . (strcmp($this->budget_amount,'') ? price2num($this->budget_amount) : 'null');
$sql.= ", " . ($this->bill_time ? 1 : 0); $sql.= ", " . ($this->bill_time ? 1 : 0);
$sql.= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : 'null');
$sql.= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : 'null');
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ")"; $sql.= ")";

View File

@ -177,7 +177,7 @@ class ProjectStats extends Stats
if (! empty($this->status)) if (! empty($this->status))
$sqlwhere[] = " t.fk_opp_status IN (" . $this->status . ")"; $sqlwhere[] = " t.fk_opp_status IN (" . $this->status . ")";
if (! $user->rights->projet->all->lire) $sqlwhere[] = " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users if (! $user->rights->projet->all->lire) $sqlwhere[] = " t.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
if (count($sqlwhere) > 0) { if (count($sqlwhere) > 0) {
$sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere); $sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere);

View File

@ -246,7 +246,18 @@ if ($action == 'createtask' && $user->rights->projet->creer)
} }
else else
{ {
setEventMessages($task->error,$task->errors,'errors'); if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("projects");
setEventMessages($langs->trans('NewTaskRefSuggested'),'', 'warnings');
$duplicate_code_error = true;
}
else
{
setEventMessages($task->error,$task->errors,'errors');
}
$action = 'create';
$error++;
} }
} }
@ -462,7 +473,14 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
// Ref // Ref
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'; print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>';
print ($_POST["ref"]?$_POST["ref"]:$defaultref); if (empty($duplicate_code_error))
{
print (GETPOSTISSET("ref")?GETPOST("ref",'alpha'):$defaultref);
}
else
{
print $defaultref;
}
print '<input type="hidden" name="taskref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'">'; print '<input type="hidden" name="taskref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'">';
print '</td></tr>'; print '</td></tr>';

View File

@ -14,6 +14,7 @@
* Copyright (C) 2015-2018 Charlene Benke <charlie@patas-monkey.com> * Copyright (C) 2015-2018 Charlene Benke <charlie@patas-monkey.com>
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 David Beniamine <David.Beniamine@Tetras-Libre.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -192,7 +193,7 @@ if (empty($reshook)) {
$birth = dol_mktime(0, 0, 0, GETPOST('birthmonth'), GETPOST('birthday'), GETPOST('birthyear')); $birth = dol_mktime(0, 0, 0, GETPOST('birthmonth'), GETPOST('birthday'), GETPOST('birthyear'));
$object->birth = $birth; $object->birth = $birth;
$object->admin = GETPOST("admin", 'alpha'); $object->admin = GETPOST("admin", 'alpha');
$object->address = GETPOST('address', 'alpha'); $object->address = GETPOST('address', 'alphanohtml');
$object->zip = GETPOST('zipcode', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha'); $object->town = GETPOST('town', 'alpha');
$object->country_id = GETPOST('country_id', 'int'); $object->country_id = GETPOST('country_id', 'int');
@ -341,7 +342,7 @@ if (empty($reshook)) {
$object->pass = GETPOST("password",'none'); $object->pass = GETPOST("password",'none');
$object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key;
if (! empty($user->admin)) $object->admin = GETPOST("admin"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request if (! empty($user->admin)) $object->admin = GETPOST("admin"); // admin flag can only be set/unset by an admin user. A test is also done later when forging sql request
$object->address = GETPOST('address', 'alpha'); $object->address = GETPOST('address', 'alphanohtml');
$object->zip = GETPOST('zipcode', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha'); $object->town = GETPOST('town', 'alpha');
$object->country_id = GETPOST('country_id', 'int'); $object->country_id = GETPOST('country_id', 'int');
@ -2137,7 +2138,16 @@ else
// Employee // Employee
print '<tr>'; print '<tr>';
print '<td>'.fieldLabel('Employee','employee',0).'</td><td>'; print '<td>'.fieldLabel('Employee','employee',0).'</td><td>';
print $form->selectyesno("employee",$object->employee,1); if ($caneditfield)
{
print $form->selectyesno("employee",$object->employee,1);
}else{
if ($object->employee){
print $langs->trans("Yes");
}else{
print $langs->trans("No");
}
}
print '</td></tr>'; print '</td></tr>';
// Hierarchy // Hierarchy
@ -2341,7 +2351,12 @@ else
{ {
print '<tr><td>'.$langs->trans("ColorUser").'</td>'; print '<tr><td>'.$langs->trans("ColorUser").'</td>';
print '<td>'; print '<td>';
print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); if ($caneditfield)
{
print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset');
}else{
print $formother->showColor($object->color, '');
}
print '</td></tr>'; print '</td></tr>';
} }
@ -2364,7 +2379,12 @@ else
foreach ($cats as $cat) { foreach ($cats as $cat) {
$arrayselected[] = $cat->id; $arrayselected[] = $cat->id;
} }
print $form->multiselectarray( 'usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' ); if ($caneditfield)
{
print $form->multiselectarray( 'usercats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%' );
}else{
print $form->showCategories( $object->id, 'user', 1 );
}
print "</td></tr>"; print "</td></tr>";
} }
@ -2447,7 +2467,12 @@ else
print $hookmanager->resPrint; print $hookmanager->resPrint;
if (empty($reshook)) if (empty($reshook))
{ {
print $object->showOptionals($extrafields,'edit'); if ($caneditfield)
{
print $object->showOptionals($extrafields,'edit');
}else{
print $object->showOptionals($extrafields,'view');
}
} }
// Signature // Signature
@ -2496,7 +2521,11 @@ else
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm'); print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">'; if($caneditfield){
print '<input size="8" type="text" name="thm" value="'.price2num(GETPOST('thm')?GETPOST('thm'):$object->thm).'">';
}else{
print ($object->thm!=''?price($object->thm,'',$langs,1,-1,-1,$conf->currency):'');
}
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -2506,7 +2535,12 @@ else
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm'); print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">'; if($caneditfield)
{
print '<input size="8" type="text" name="tjm" value="'.price2num(GETPOST('tjm')?GETPOST('tjm'):$object->tjm).'">';
}else{
print ($object->tjm!=''?price($object->tjm,'',$langs,1,-1,-1,$conf->currency):'');
}
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -2521,21 +2555,36 @@ else
// Weeklyhours // Weeklyhours
print '<tr><td>'.$langs->trans("WeeklyHours").'</td>'; print '<tr><td>'.$langs->trans("WeeklyHours").'</td>';
print '<td>'; print '<td>';
print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">'; if($caneditfield)
{
print '<input size="8" type="text" name="weeklyhours" value="'.price2num(GETPOST('weeklyhours')?GETPOST('weeklyhours'):$object->weeklyhours).'">';
}else{
print price2num($object->weeklyhours);
}
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Date employment // Date employment
print '<tr><td>'.$langs->trans("DateEmployment").'</td>'; print '<tr><td>'.$langs->trans("DateEmployment").'</td>';
print '<td>'; print '<td>';
print $form->selectDate(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0); if($caneditfield)
{
print $form->selectDate(GETPOST('dateemployment')?GETPOST('dateemployment'):$object->dateemployment, 'dateemployment', 0, 0, 1, 'formdateemployment', 1, 0);
}else{
print dol_print_date($object->dateemployment, 'day');
}
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Date employmentEnd // Date employmentEnd
print '<tr><td>'.$langs->trans("DateEmploymentEnd").'</td>'; print '<tr><td>'.$langs->trans("DateEmploymentEnd").'</td>';
print '<td>'; print '<td>';
print $form->selectDate(GETPOST('dateemploymentend')?GETPOST('dateemploymentend'):$object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0); if($caneditfield)
{
print $form->selectDate(GETPOST('dateemploymentend')?GETPOST('dateemploymentend'):$object->dateemploymentend, 'dateemploymentend', 0, 0, 1, 'formdateemploymentend', 1, 0);
}else{
print dol_print_date($object->dateemploymentend, 'day');
}
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -2543,7 +2592,12 @@ else
// Date birth // Date birth
print '<tr><td>'.$langs->trans("DateToBirth").'</td>'; print '<tr><td>'.$langs->trans("DateToBirth").'</td>';
print '<td>'; print '<td>';
print $form->selectDate(GETPOST('birth')?GETPOST('birth'):$object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0); if($caneditfield)
{
echo $form->selectDate(GETPOST('birth')?GETPOST('birth'):$object->birth, 'birth', 0, 0, 1, 'updateuser', 1, 0);
}else{
print dol_print_date($object->birth, 'day');
}
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -764,7 +764,7 @@ class User extends CommonObject
// Recuperation des droits utilisateurs + recuperation des droits groupes // Recuperation des droits utilisateurs + recuperation des droits groupes
// D'abord les droits utilisateurs // D'abord les droits utilisateurs
$sql = "SELECT r.module, r.perms, r.subperms"; $sql = "SELECT DISTINCT r.module, r.perms, r.subperms";
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = ur.fk_id"; $sql.= " WHERE r.id = ur.fk_id";
@ -818,7 +818,7 @@ class User extends CommonObject
} }
// Maintenant les droits groupes // Maintenant les droits groupes
$sql = "SELECT r.module, r.perms, r.subperms"; $sql = "SELECT DISTINCT r.module, r.perms, r.subperms";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,";
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
$sql.= " ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " ".MAIN_DB_PREFIX."rights_def as r";

View File

@ -261,15 +261,18 @@ print '<div class="div-table-responsive">';
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Module").'</td>'; print '<td>'.$langs->trans("Module").'</td>';
if ($caneditperms && empty($objMod->rights_admin_allowed) || empty($object->admin)) if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin))
{ {
print '<td align="center" class="nowrap">'; if ($caneditperms)
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>"; {
print '/'; print '<td align="center" class="nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>"; print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '</td>'; print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '</td>';
}
print '<td align="center" width="24">&nbsp;</td>';
} }
print '<td align="center" width="24">&nbsp;</td>';
print '<td>'.$langs->trans("Permissions").'</td>'; print '<td>'.$langs->trans("Permissions").'</td>';
print '</tr>'."\n"; print '</tr>'."\n";
@ -310,21 +313,31 @@ if ($result)
print '<tr class="oddeven trforbreak">'; print '<tr class="oddeven trforbreak">';
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName(); print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName();
print '<a name="'.$objMod->getName().'"></a></td>'; print '<a name="'.$objMod->getName().'"></a></td>';
print '<td align="center" class="nowrap">'; if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin))
if ($caneditperms && empty($objMod->rights_admin_allowed) || empty($object->admin))
{ {
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>"; if ($caneditperms)
print '/'; {
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("None")."</a>"; print '<td align="center" class="nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("All")."</a>";
print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module='.$obj->module.'">'.$langs->trans("None")."</a>";
print '</td>';
}
}
else
{
if ($caneditperms)
{
print '<td></td>';
}
} }
print '</td>';
print '<td colspan="2">&nbsp;</td>'; print '<td colspan="2">&nbsp;</td>';
print '</tr>'."\n"; print '</tr>'."\n";
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Picto and label of permission // Picto and label of module
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName().'</td>'; print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName().'</td>';
// Permission and tick // Permission and tick
@ -383,6 +396,7 @@ if ($result)
print '<td>&nbsp</td>'; print '<td>&nbsp</td>';
} }
// Label
$permlabel=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->libelle))); $permlabel=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->libelle)));
print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>'; print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>';

View File

@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
$langs->loadLangs(array("admin","other","website")); $langs->loadLangs(array("admin","other","website"));
if (! $user->admin) accessforbidden(); if (! $user->rights->website->read) accessforbidden();
if (! ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))) if (! ((GETPOST('testmenuhider','int') || ! empty($conf->global->MAIN_TESTMENUHIDER)) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)))
{ {