Merge remote-tracking branch 'upstream/develop' into actionrefused
This commit is contained in:
commit
ce6b7adaa0
@ -69,7 +69,15 @@ class BookKeeping extends CommonObject
|
||||
|
||||
public $doc_date;
|
||||
public $date_lim_reglement;
|
||||
public $doc_type;
|
||||
|
||||
/**
|
||||
* @var string doc_type
|
||||
*/
|
||||
public $doc_type;
|
||||
|
||||
/**
|
||||
* @var string doc_ref
|
||||
*/
|
||||
public $doc_ref;
|
||||
|
||||
/**
|
||||
@ -82,12 +90,35 @@ class BookKeeping extends CommonObject
|
||||
*/
|
||||
public $fk_docdet;
|
||||
|
||||
public $thirdparty_code;
|
||||
/**
|
||||
* @var string thirdparty code
|
||||
*/
|
||||
public $thirdparty_code;
|
||||
|
||||
/**
|
||||
* @var string subledger account
|
||||
*/
|
||||
public $subledger_account;
|
||||
|
||||
/**
|
||||
* @var string subledger label
|
||||
*/
|
||||
public $subledger_label;
|
||||
|
||||
/**
|
||||
* @var string doc_type
|
||||
*/
|
||||
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 $credit;
|
||||
public $montant;
|
||||
|
||||
@ -426,7 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Add filter
|
||||
print '<tr class="oddeven">';
|
||||
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 '</td><td>';
|
||||
print '<input type="text" name="rulevalue">';
|
||||
@ -464,7 +464,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
// Add operation
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
$arrayoftypes=array('recordevent'=>'RecordEvent');
|
||||
$arrayoftypes=array('loadthirdparty'=>'LoadThirdPartyFromName', 'loadandcreatethirdparty'=>'LoadThirdPartyFromNameOrCreate', 'recordevent'=>'RecordEvent');
|
||||
if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty';
|
||||
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1);
|
||||
print '</td><td>';
|
||||
|
||||
@ -232,13 +232,13 @@ print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
//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 '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->END_TO_END.'" size="15" ></td>';
|
||||
print '</td></tr>';
|
||||
|
||||
//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 '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->USTRD.'" size="15" ></td>';
|
||||
print '</td></tr>';
|
||||
|
||||
@ -380,6 +380,7 @@ if (empty($reshook))
|
||||
}
|
||||
} else {
|
||||
$object->ref = GETPOST('ref');
|
||||
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
|
||||
$object->ref_client = GETPOST('ref_client');
|
||||
$object->datep = $datep;
|
||||
$object->date_livraison = $date_delivery;
|
||||
|
||||
@ -874,6 +874,7 @@ class Propal extends CommonObject
|
||||
$now=dol_now();
|
||||
|
||||
// Clean parameters
|
||||
if (empty($this->entity)) $this->entity = $conf->entity;
|
||||
if (empty($this->date)) $this->date=$this->datep;
|
||||
$this->fin_validite = $this->date + ($this->duree_validite * 24 * 3600);
|
||||
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.= ", ".(int) $this->fk_incoterms;
|
||||
$sql.= ", '".$this->db->escape($this->location_incoterms)."'";
|
||||
$sql.= ", ".$conf->entity;
|
||||
$sql.= ", ".$this->entity;
|
||||
$sql.= ", ".(int) $this->fk_multicurrency;
|
||||
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
|
||||
$sql.= ", ".(double) $this->multicurrency_tx;
|
||||
@ -3428,13 +3429,7 @@ class Propal extends CommonObject
|
||||
global $conf,$langs;
|
||||
$langs->load("propal");
|
||||
|
||||
$constant = 'PROPALE_ADDON_'.$this->entity;
|
||||
|
||||
if (! empty($conf->global->$constant)) {
|
||||
$classname = $conf->global->$constant; // for multicompany proposal sharing
|
||||
} else {
|
||||
$classname = $conf->global->PROPALE_ADDON;
|
||||
}
|
||||
$classname = $conf->global->PROPALE_ADDON;
|
||||
|
||||
if (! empty($classname))
|
||||
{
|
||||
|
||||
@ -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
|
||||
$hookmanager->initHooks(array('invoicecard','globalcard'));
|
||||
|
||||
$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
|
||||
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
|
||||
$usercanread = $user->rights->facture->lire;
|
||||
$usercancreate = $user->rights->facture->creer;
|
||||
$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
|
||||
$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
|
||||
|
||||
// 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"])) {
|
||||
// $mesgs [] = '<div class="error">' . $langs->trans("NoCloneOptionsSpecified") . '</div>';
|
||||
// } else {
|
||||
@ -165,7 +179,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Change status of invoice
|
||||
else if ($action == 'reopen' && $user->rights->facture->creer) {
|
||||
else if ($action == 'reopen' && $usercancreate) {
|
||||
$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
|
||||
$result = $object->set_unpaid($user);
|
||||
@ -194,8 +208,8 @@ if (empty($reshook))
|
||||
|
||||
$isErasable=$object->is_erasable();
|
||||
|
||||
if (($user->rights->facture->supprimer && $isErasable > 0)
|
||||
|| ($user->rights->facture->creer && $isErasable == 1))
|
||||
if (($usercandelete && $isErasable > 0)
|
||||
|| ($usercancreate && $isErasable == 1))
|
||||
{
|
||||
$result = $object->delete($user, 0, $idwarehouse);
|
||||
if ($result > 0) {
|
||||
@ -209,7 +223,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// 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_thirdparty();
|
||||
@ -243,7 +257,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Delete link of credit note to invoice
|
||||
else if ($action == 'unlinkdiscount' && $user->rights->facture->creer)
|
||||
else if ($action == 'unlinkdiscount' && $usercancreate)
|
||||
{
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$result = $discount->fetch(GETPOST("discountid"));
|
||||
@ -251,7 +265,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Validation
|
||||
else if ($action == 'valid' && $user->rights->facture->creer)
|
||||
else if ($action == 'valid' && $usercancreate)
|
||||
{
|
||||
$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->setValueFrom('fk_soc', $socid, '', null, 'int', '', $user, 'BILL_MODIFY');
|
||||
@ -280,13 +294,13 @@ if (empty($reshook))
|
||||
exit();
|
||||
}
|
||||
|
||||
else if ($action == 'classin' && $user->rights->facture->creer)
|
||||
else if ($action == 'classin' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->setProject($_POST['projectid']);
|
||||
}
|
||||
|
||||
else if ($action == 'setmode' && $user->rights->facture->creer)
|
||||
else if ($action == 'setmode' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
@ -295,16 +309,16 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Multicurrency Code
|
||||
else if ($action == 'setmulticurrencycode' && $user->rights->facture->creer) {
|
||||
else if ($action == 'setmulticurrencycode' && $usercancreate) {
|
||||
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
|
||||
}
|
||||
|
||||
// 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'));
|
||||
}
|
||||
|
||||
else if ($action == 'setinvoicedate' && $user->rights->facture->creer)
|
||||
else if ($action == 'setinvoicedate' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$old_date_lim_reglement = $object->date_lim_reglement;
|
||||
@ -323,7 +337,7 @@ if (empty($reshook))
|
||||
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);
|
||||
$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);
|
||||
}
|
||||
|
||||
else if ($action == 'setconditions' && $user->rights->facture->creer)
|
||||
else if ($action == 'setconditions' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->cond_reglement_code = 0; // To clean property
|
||||
@ -348,7 +362,7 @@ if (empty($reshook))
|
||||
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->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);
|
||||
}
|
||||
|
||||
else if ($action == 'setrevenuestamp' && $user->rights->facture->creer)
|
||||
else if ($action == 'setrevenuestamp' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->revenuestamp = GETPOST('revenuestamp');
|
||||
@ -378,18 +392,18 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// bank account
|
||||
else if ($action == 'setbankaccount' && $user->rights->facture->creer)
|
||||
else if ($action == 'setbankaccount' && $usercancreate)
|
||||
{
|
||||
$result=$object->setBankAccount(GETPOST('fk_account', 'int'));
|
||||
}
|
||||
|
||||
else if ($action == 'setremisepercent' && $user->rights->facture->creer)
|
||||
else if ($action == 'setremisepercent' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$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]
|
||||
|
||||
@ -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->set_ref_client(GETPOST('ref_client'));
|
||||
}
|
||||
|
||||
// Classify to validated
|
||||
else if ($action == 'confirm_valid' && $confirm == 'yes' &&
|
||||
((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)))
|
||||
)
|
||||
else if ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate)
|
||||
{
|
||||
$idwarehouse = GETPOST('idwarehouse','int');
|
||||
|
||||
@ -557,10 +568,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Go back to draft status (unvalidate)
|
||||
else if ($action == 'confirm_modif' &&
|
||||
((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)))
|
||||
)
|
||||
else if ($action == 'confirm_modif' && $usercanunvalidate)
|
||||
{
|
||||
$idwarehouse = GETPOST('idwarehouse','int');
|
||||
|
||||
@ -640,13 +648,13 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Classify "paid"
|
||||
else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement)
|
||||
else if ($action == 'confirm_paid' && $confirm == 'yes' && $usercanissuepayment)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->set_paid($user);
|
||||
if ($result<0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
} // 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);
|
||||
$close_code = GETPOST("close_code",'none');
|
||||
@ -671,7 +679,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// 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_thirdparty();
|
||||
@ -797,7 +805,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Delete payment
|
||||
elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $user->rights->facture->creer)
|
||||
elseif ($action == 'confirm_delete_paiement' && $confirm == 'yes' && $usercancreate)
|
||||
{
|
||||
$object->fetch($id);
|
||||
if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0)
|
||||
@ -817,7 +825,7 @@ if (empty($reshook))
|
||||
/*
|
||||
* 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');
|
||||
|
||||
@ -869,6 +877,7 @@ if (empty($reshook))
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
|
||||
|
||||
// Proprietes particulieres a facture de remplacement
|
||||
$object->fk_facture_source = $_POST['fac_replacement'];
|
||||
@ -921,6 +930,7 @@ if (empty($reshook))
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
|
||||
|
||||
// Proprietes particulieres a facture avoir
|
||||
$object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : '';
|
||||
@ -1102,6 +1112,7 @@ if (empty($reshook))
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
|
||||
|
||||
// Source facture
|
||||
$object->fac_rec = GETPOST('fac_rec', 'int');
|
||||
@ -1152,6 +1163,7 @@ if (empty($reshook))
|
||||
$object->location_incoterms = GETPOST('location_incoterms', 'alpha');
|
||||
$object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
|
||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||
$object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity);
|
||||
|
||||
if (GETPOST('type') == Facture::TYPE_SITUATION)
|
||||
{
|
||||
@ -1634,7 +1646,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Add a new line
|
||||
else if ($action == 'addline' && $user->rights->facture->creer)
|
||||
else if ($action == 'addline' && $usercancreate)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$error = 0;
|
||||
@ -1967,7 +1979,7 @@ if (empty($reshook))
|
||||
if ($tva_npr)
|
||||
$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));
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
} 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);
|
||||
$object->fetch_thirdparty();
|
||||
@ -2130,7 +2142,7 @@ if (empty($reshook))
|
||||
$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)
|
||||
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');
|
||||
$error++;
|
||||
}
|
||||
@ -2167,7 +2179,7 @@ if (empty($reshook))
|
||||
|
||||
// Update line
|
||||
if (! $error) {
|
||||
if (empty($user->rights->margins->creer))
|
||||
if (empty($usercancreatemargin))
|
||||
{
|
||||
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 (!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
|
||||
exit();
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
if ($object->statut == Facture::STATUS_VALIDATED
|
||||
&& $object->type == Facture::TYPE_SITUATION
|
||||
&& $user->rights->facture->creer
|
||||
&& $usercancreate
|
||||
&& !$objectidnext
|
||||
&& $object->is_last_in_cycle()
|
||||
&& ((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)))
|
||||
&& $usercanunvalidate
|
||||
)
|
||||
{
|
||||
$outingError = 0;
|
||||
@ -2388,7 +2399,7 @@ if (empty($reshook))
|
||||
|
||||
// add lines from objectlinked
|
||||
elseif($action == 'import_lines_from_object'
|
||||
&& $user->rights->facture->creer
|
||||
&& $usercancreate
|
||||
&& $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))
|
||||
{
|
||||
@ -2481,7 +2492,7 @@ if (empty($reshook))
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->facture->dir_output;
|
||||
$permissioncreate=$user->rights->facture->creer;
|
||||
$permissioncreate=$usercancreate;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
|
||||
@ -2508,7 +2519,7 @@ if (empty($reshook))
|
||||
$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') {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
@ -3474,11 +3485,10 @@ else if ($id > 0 || ! empty($ref))
|
||||
$formquestion = array();
|
||||
// remove situation from cycle
|
||||
if ($object->statut == Facture::STATUS_VALIDATED
|
||||
&& $user->rights->facture->creer
|
||||
&& $usercancreate
|
||||
&& !$objectidnext
|
||||
&& $object->is_last_in_cycle()
|
||||
&& ((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)))
|
||||
&& $usercanunvalidate
|
||||
)
|
||||
{
|
||||
$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">';
|
||||
// Ref customer
|
||||
$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1);
|
||||
$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 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, $usercancreate, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$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>)';
|
||||
@ -3699,7 +3709,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
|
||||
if ($user->rights->facture->creer)
|
||||
if ($usercancreate)
|
||||
{
|
||||
if ($action != 'classify')
|
||||
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&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 $langs->trans('DateInvoice');
|
||||
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&facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
@ -3839,7 +3849,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentConditionsShort');
|
||||
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&facid=' . $object->id . '">' . img_edit($langs->trans('SetConditions'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
@ -3860,7 +3870,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('DateMaxPayment');
|
||||
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&facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
@ -3884,7 +3894,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('PaymentMode');
|
||||
print '</td>';
|
||||
if ($action != 'editmode' && $user->rights->facture->creer)
|
||||
if ($action != 'editmode' && $usercancreate)
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editmode&facid=' . $object->id . '">' . img_edit($langs->trans('SetMode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
@ -3907,15 +3917,12 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('Currency','multicurrency_code');
|
||||
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&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editmulticurrencycode') {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code');
|
||||
} else {
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none');
|
||||
}
|
||||
$htmlname = (($usercancreate && $action == 'editmulticurrencycode')?'multicurrency_code':'none');
|
||||
$form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, $htmlname);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr>';
|
||||
@ -3923,7 +3930,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print fieldLabel('CurrencyRate','multicurrency_tx');
|
||||
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&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
@ -3931,7 +3938,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if($action == 'actualizemulticurrencyrate') {
|
||||
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 {
|
||||
$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) {
|
||||
@ -3948,7 +3955,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||
print $langs->trans('BankAccount');
|
||||
print '<td>';
|
||||
if (($action != 'editbankaccount') && $user->rights->facture->creer)
|
||||
if (($action != 'editbankaccount') && $usercancreate)
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
@ -3975,7 +3982,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('IncotermLabel');
|
||||
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 ' ';
|
||||
print '</td></tr></table>';
|
||||
print '</td>';
|
||||
@ -4049,7 +4056,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('RevenueStamp');
|
||||
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&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))
|
||||
{
|
||||
print '<td align="right" class="margininfos" width="80"> </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"> </td>';
|
||||
}
|
||||
}
|
||||
@ -4576,7 +4583,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1);
|
||||
|
||||
// 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')
|
||||
{
|
||||
@ -4617,8 +4624,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
if (! $objectidnext && $object->is_last_in_cycle())
|
||||
{
|
||||
if ((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)))
|
||||
if ($usercanunvalidate)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER['PHP_SELF'] . '?facid=' . $object->id . '&action=modif">' . $langs->trans('Modify') . '</a></div>';
|
||||
} else {
|
||||
@ -4645,7 +4651,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
|| ($object->type == Facture::TYPE_CREDIT_NOTE && 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
|
||||
&& ((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
|
||||
{
|
||||
@ -4657,8 +4663,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
|
||||
// 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 ((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)))
|
||||
if ($usercanvalidate)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction'.($conf->use_javascript_ajax?' reposition':'').'" href="' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&action=valid">' . $langs->trans('Validate') . '</a></div>';
|
||||
}
|
||||
@ -4669,7 +4674,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
if ($objectidnext) {
|
||||
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('SendMail') . '</span></div>';
|
||||
} 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>';
|
||||
} else
|
||||
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 ($user->rights->prelevement->bons->creer)
|
||||
if ($usercancreatewithdrarequest)
|
||||
{
|
||||
if (! $objectidnext && $object->close_code != 'replaced') // Not replaced by another invoice
|
||||
{
|
||||
@ -4702,7 +4707,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// 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) {
|
||||
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="' . $langs->trans("DisabledBecauseReplacedInvoice") . '">' . $langs->trans('DoPayment') . '</span></div>';
|
||||
} else {
|
||||
@ -4717,7 +4722,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Reverse back money or convert to reduction
|
||||
if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD) {
|
||||
// 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)
|
||||
{
|
||||
@ -4730,24 +4735,24 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// 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.'&action=converttoreduc">'.$langs->trans('ConvertExcessReceivedToReduc').'</a></div>';
|
||||
}
|
||||
// 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 . '&action=converttoreduc">' . $langs->trans('ConvertToReduc') . '</a></div>';
|
||||
}
|
||||
// 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.'&action=converttoreduc">'.$langs->trans('ConvertToReduc').'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// 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))
|
||||
|| ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id))
|
||||
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 && $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.'&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)
|
||||
|
||||
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)
|
||||
{
|
||||
@ -4779,13 +4784,13 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// 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 . '&action=clone&object=invoice">' . $langs->trans("ToClone") . '</a></div>';
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
@ -4794,7 +4799,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
@ -4805,14 +4810,13 @@ else if ($id > 0 || ! empty($ref))
|
||||
// For situation invoice with excess received
|
||||
if ($object->statut > Facture::STATUS_DRAFT
|
||||
&& ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0
|
||||
&& $user->rights->facture->creer
|
||||
&& $usercancreate
|
||||
&& !$objectidnext
|
||||
&& $object->is_last_in_cycle()
|
||||
&& $conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE
|
||||
)
|
||||
{
|
||||
if ((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)))
|
||||
if ($usercanunvalidate)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->socid .'&fac_avoir=' . $object->id . '&invoiceAvoirWithLines=1&action=create&type=2'.($object->fk_project > 0 ? '&projectid='.$object->fk_project : '').'">' . $langs->trans("CreateCreditNote") . '</a></div>';
|
||||
} else {
|
||||
@ -4823,12 +4827,11 @@ else if ($id > 0 || ! empty($ref))
|
||||
// remove situation from cycle
|
||||
if ($object->statut > Facture::STATUS_DRAFT
|
||||
&& $object->type == Facture::TYPE_SITUATION
|
||||
&& $user->rights->facture->creer
|
||||
&& $usercancreate
|
||||
&& !$objectidnext
|
||||
&& $object->situation_counter > 1
|
||||
&& $object->is_last_in_cycle()
|
||||
&& ((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)))
|
||||
&& $usercanunvalidate
|
||||
)
|
||||
{
|
||||
if(($object->total_ttc - $totalcreditnotes ) == 0 )
|
||||
@ -4842,7 +4845,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
// 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) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=create&type=5&origin=facture&originid=' . $object->id . '&socid=' . $object->socid . '" >' . $langs->trans('CreateNextSituationInvoice') . '</a></div>';
|
||||
} else if (!$object->is_last_in_cycle()) {
|
||||
@ -4854,7 +4857,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Delete
|
||||
$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);
|
||||
if ($isErasable == -4) {
|
||||
@ -4901,8 +4904,8 @@ else if ($id > 0 || ! empty($ref))
|
||||
$filename = dol_sanitizeFileName($object->ref);
|
||||
$filedir = $conf->facture->dir_output . '/' . dol_sanitizeFileName($object->ref);
|
||||
$urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $object->id;
|
||||
$genallowed = $user->rights->facture->lire;
|
||||
$delallowed = $user->rights->facture->creer;
|
||||
$genallowed = $usercanread;
|
||||
$delallowed = $usercancreate;
|
||||
|
||||
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
||||
$somethingshown = $formfile->numoffiles;
|
||||
@ -4911,7 +4914,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
|
||||
|
||||
$compatibleImportElementsList = false;
|
||||
if($user->rights->facture->creer
|
||||
if($usercancreate
|
||||
&& $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) )
|
||||
{
|
||||
|
||||
@ -231,9 +231,10 @@ $disable_delete = 0;
|
||||
// Bank account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
|
||||
if ($object->fk_account > 0)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($object->bank_line);
|
||||
if ($bankline->rappro)
|
||||
{
|
||||
|
||||
@ -1731,7 +1731,7 @@ function email_admin_prepare_head()
|
||||
$h = 0;
|
||||
$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][1] = $langs->trans("OutGoingEmailSetup");
|
||||
@ -1752,7 +1752,7 @@ function email_admin_prepare_head()
|
||||
$head[$h][2] = 'templates';
|
||||
$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][1] = $langs->trans("EmailSenderProfiles");
|
||||
|
||||
@ -2837,35 +2837,50 @@ function isValidPhone($phone)
|
||||
* @param string $stringencoding Encoding 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);
|
||||
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 $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 int $trunconbytes 1=Length is max of bytes instead of max of characters
|
||||
* @return string substring
|
||||
*/
|
||||
function dol_substr($string,$start,$length,$stringencoding='')
|
||||
function dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
if (empty($stringencoding)) $stringencoding=$langs->charset_output;
|
||||
|
||||
$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
|
||||
{
|
||||
$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;
|
||||
}
|
||||
@ -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 $stringencoding Tell what is source string encoding
|
||||
* @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.
|
||||
*/
|
||||
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 '';
|
||||
|
||||
// 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.= " FROM ".MAIN_DB_PREFIX.$tablename;
|
||||
$sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'";
|
||||
if (! empty($entityfilter))
|
||||
$sql.= " AND entity IN (" . getEntity($tablename) . ")";
|
||||
|
||||
dol_syslog('dol_getIdFromCode', LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $cache_codes[$tablename][$key]=$obj->valuetoget;
|
||||
else $cache_codes[$tablename][$key]='';
|
||||
if ($obj) $cache_codes[$tablename][$key][$fieldid]=$obj->valuetoget;
|
||||
else $cache_codes[$tablename][$key][$fieldid]='';
|
||||
$db->free($resql);
|
||||
return $cache_codes[$tablename][$key];
|
||||
return $cache_codes[$tablename][$key][$fieldid];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -6889,8 +6905,6 @@ function picto_from_langcode($codelang, $moreatt = '')
|
||||
|
||||
if (empty($codelang)) return '';
|
||||
|
||||
if (empty($codelang)) return '';
|
||||
|
||||
if ($codelang == 'auto')
|
||||
{
|
||||
return '<span class="fa fa-globe"></span>';
|
||||
|
||||
@ -990,7 +990,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
if ($bentityon) // only if entity enable
|
||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
$sql.= " AND entity = ".(int) $forceentity;
|
||||
$sql.= " AND entity IN (".$forceentity.")";
|
||||
if ($where) $sql.=$where;
|
||||
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
|
||||
$sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
else if (! empty($forceentity))
|
||||
$sql.= " AND entity = ".(int) $forceentity;
|
||||
$sql.= " AND entity IN (".$forceentity.")";
|
||||
if ($where) $sql.=$where;
|
||||
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
|
||||
$maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")";
|
||||
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 ($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."')";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* @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
|
||||
* @return string Value
|
||||
*/
|
||||
function getNextValue($objsoc,$facture,$mode='next')
|
||||
function getNextValue($objsoc, $invoice, $mode='next')
|
||||
{
|
||||
global $db;
|
||||
|
||||
$prefix=$this->prefixinvoice;
|
||||
|
||||
if ($facture->type == 1) $prefix=$this->prefixreplacement;
|
||||
else if ($facture->type == 2) $prefix=$this->prefixcreditnote;
|
||||
else if ($facture->type == 3) $prefix=$this->prefixdeposit;
|
||||
if ($invoice->type == 1) $prefix=$this->prefixreplacement;
|
||||
else if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
|
||||
else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
|
||||
else $prefix=$this->prefixinvoice;
|
||||
|
||||
// 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.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
||||
$sql.= " AND entity IN (".getEntity('invoicenumber').")";
|
||||
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||
@ -189,7 +189,7 @@ class mod_facture_mars extends ModeleNumRefFactures
|
||||
$sql = "SELECT facnumber as ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$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);
|
||||
$resql=$db->query($sql);
|
||||
@ -204,7 +204,7 @@ class mod_facture_mars extends ModeleNumRefFactures
|
||||
}
|
||||
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);
|
||||
|
||||
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
|
||||
|
||||
@ -131,19 +131,19 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
||||
* Return next value
|
||||
*
|
||||
* @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
|
||||
* @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
|
||||
$mask = '';
|
||||
if (is_object($facture) && $facture->type == 1)
|
||||
if (is_object($invoice) && $invoice->type == 1)
|
||||
{
|
||||
$mask=$conf->global->FACTURE_MERCURE_MASK_REPLACEMENT;
|
||||
if (! $mask)
|
||||
@ -151,8 +151,8 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
||||
$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($facture) && $facture->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
|
||||
else if (is_object($invoice) && $invoice->type == 2) $mask=$conf->global->FACTURE_MERCURE_MASK_CREDIT;
|
||||
else if (is_object($invoice) && $invoice->type == 3) $mask=$conf->global->FACTURE_MERCURE_MASK_DEPOSIT;
|
||||
else $mask=$conf->global->FACTURE_MERCURE_MASK_INVOICE;
|
||||
if (! $mask)
|
||||
{
|
||||
@ -160,14 +160,17 @@ class mod_facture_mercure extends ModeleNumRefFactures
|
||||
return 0;
|
||||
}
|
||||
|
||||
$where='';
|
||||
//if ($facture->type == 2) $where.= " AND type = 2";
|
||||
//else $where.=" AND type != 2";
|
||||
$where='';
|
||||
//if ($facture->type == 2) $where.= " AND type = 2";
|
||||
//else $where.=" AND type != 2";
|
||||
|
||||
$numFinal=get_next_value($db,$mask,'facture','facnumber',$where,$objsoc,$facture->date,$mode);
|
||||
if (! preg_match('/([0-9])+/',$numFinal)) $this->error = $numFinal;
|
||||
// Get entities
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -163,16 +163,16 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
* Return next value not used or last value used
|
||||
*
|
||||
* @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
|
||||
* @return string Value
|
||||
*/
|
||||
function getNextValue($objsoc,$facture,$mode='next')
|
||||
function getNextValue($objsoc, $invoice, $mode='next')
|
||||
{
|
||||
global $db;
|
||||
|
||||
if ($facture->type == 2) $prefix=$this->prefixcreditnote;
|
||||
else if ($facture->type == 3) $prefix=$this->prefixdeposit;
|
||||
if ($invoice->type == 2) $prefix=$this->prefixcreditnote;
|
||||
else if ($invoice->type == 3) $prefix=$this->prefixdeposit;
|
||||
else $prefix=$this->prefixinvoice;
|
||||
|
||||
// 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.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
|
||||
$sql.= " AND entity IN (".getEntity('invoicenumber').")";
|
||||
$sql.= " AND entity IN (".getEntity('invoicenumber', 1, $invoice).")";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
|
||||
@ -204,7 +204,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
$sql = "SELECT facnumber as ref";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
|
||||
$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);
|
||||
$resql=$db->query($sql);
|
||||
@ -219,7 +219,7 @@ class mod_facture_terre extends ModeleNumRefFactures
|
||||
}
|
||||
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);
|
||||
|
||||
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
|
||||
|
||||
@ -122,7 +122,7 @@ class mod_project_simple extends ModeleNumRefProjects
|
||||
* @param Project $project Object project
|
||||
* @return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc,$project)
|
||||
function getNextValue($objsoc, $project)
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
@ -167,9 +167,9 @@ class mod_project_simple extends ModeleNumRefProjects
|
||||
* @param Project $project Object project
|
||||
* @return string Next not used reference
|
||||
*/
|
||||
function project_get_num($objsoc=0,$project='')
|
||||
function project_get_num($objsoc=0, $project='')
|
||||
{
|
||||
// phpcs:enable
|
||||
return $this->getNextValue($objsoc,$project);
|
||||
return $this->getNextValue($objsoc, $project);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ class mod_project_universal extends ModeleNumRefProjects
|
||||
* @param Project $project Object project
|
||||
* @return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc,$project)
|
||||
function getNextValue($objsoc, $project)
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
@ -139,7 +139,7 @@ class mod_project_universal extends ModeleNumRefProjects
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
@ -153,9 +153,9 @@ class mod_project_universal extends ModeleNumRefProjects
|
||||
* @param Project $project Object project
|
||||
* @return string Next not used reference
|
||||
*/
|
||||
function project_get_num($objsoc=0,$project='')
|
||||
function project_get_num($objsoc=0, $project='')
|
||||
{
|
||||
// phpcs:enable
|
||||
return $this->getNextValue($objsoc,$project);
|
||||
return $this->getNextValue($objsoc, $project);
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,15 +128,12 @@ class mod_propale_marbre extends ModeleNumRefPropales
|
||||
{
|
||||
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
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
|
||||
$sql.= " AND entity = ".$entity;
|
||||
$sql.= " AND entity IN (".getEntity('proposalnumber', 1, $propal).")";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -134,14 +134,8 @@ class mod_propale_saphir extends ModeleNumRefPropales
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
|
||||
|
||||
$constant = 'PROPALE_SAPHIR_MASK_'.$propal->entity;
|
||||
|
||||
// On defini critere recherche compteur
|
||||
if (! empty($conf->global->$constant)) {
|
||||
$mask = $conf->global->$constant; // for multicompany proposal sharing
|
||||
} else {
|
||||
$mask = $conf->global->PROPALE_SAPHIR_MASK;
|
||||
}
|
||||
$mask = $conf->global->PROPALE_SAPHIR_MASK;
|
||||
|
||||
if (! $mask)
|
||||
{
|
||||
@ -149,8 +143,8 @@ class mod_propale_saphir extends ModeleNumRefPropales
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Use object entity ID
|
||||
$entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity);
|
||||
// Get entities
|
||||
$entity = getEntity('proposalnumber', 1, $propal);
|
||||
|
||||
$date = $propal->date;
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ if (empty($conf) || ! is_object($conf))
|
||||
if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey=$object->table_element;
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
*/
|
||||
public $ismultientitymanaged = 0;
|
||||
public $ismultientitymanaged = 1;
|
||||
/**
|
||||
* @var int Does emailcollector support extrafields ? 0=No, 1=Yes
|
||||
*/
|
||||
@ -697,6 +697,94 @@ class EmailCollector extends CommonObject
|
||||
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.
|
||||
*
|
||||
@ -708,14 +796,16 @@ class EmailCollector extends CommonObject
|
||||
|
||||
//$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);
|
||||
|
||||
$langs->loadLangs(array("project", "companies", "errors"));
|
||||
|
||||
$error = 0;
|
||||
$this->output = '';
|
||||
$this->error='';
|
||||
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
if (empty($this->host))
|
||||
@ -778,13 +868,12 @@ class EmailCollector extends CommonObject
|
||||
if ($this->datelastresult && $this->codelastresult == 'OK') $fromdate = $this->datelastresult;
|
||||
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);
|
||||
|
||||
$nbemailprocessed=0; $nbactiondone=0;
|
||||
$projectstatic=new Project($this->db);
|
||||
$thirdpartystatic=new Societe($this->db);
|
||||
$contactstatic=new Contact($this->db);
|
||||
$nbemailprocessed=0;
|
||||
$nbemailok=0;
|
||||
$nbactiondone=0;
|
||||
|
||||
// Scan IMAP inbox
|
||||
$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
|
||||
|
||||
$thirdpartystatic=new Societe($this->db);
|
||||
$contactstatic=new Contact($this->db);
|
||||
$projectstatic=new Project($this->db);
|
||||
|
||||
$nbactiondoneforemail = 0;
|
||||
$errorforemail = 0;
|
||||
$errorforactions = 0;
|
||||
$thirdpartyfoundby = '';
|
||||
$contactfoundby = '';
|
||||
$projectfoundby = '';
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -830,8 +928,9 @@ class EmailCollector extends CommonObject
|
||||
$sendtocc=$overview[0]->cc;
|
||||
$sendtobcc=$overview[0]->bcc;
|
||||
$date=$overview[0]->udate;
|
||||
$msgid=$overview[0]->message_id;
|
||||
$msgid=str_replace(array('<','>'), '', $overview[0]->message_id);
|
||||
$subject=$overview[0]->subject;
|
||||
//var_dump($msgid);exit;
|
||||
|
||||
$reg=array();
|
||||
if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg))
|
||||
@ -845,12 +944,16 @@ class EmailCollector extends CommonObject
|
||||
$fromtext='';
|
||||
}
|
||||
$fk_element_id = 0; $fk_element_type = '';
|
||||
|
||||
$contactid = 0; $thirdpartyid = 0; $projectid = 0;
|
||||
|
||||
// Analyze TrackId
|
||||
$trackid = '';
|
||||
$reg=array();
|
||||
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;
|
||||
$objectemail = null;
|
||||
if ($reg[0] == 'inv')
|
||||
@ -888,50 +991,93 @@ class EmailCollector extends CommonObject
|
||||
if ($fk_element_type == 'facture') $fk_element_type = 'invoice';
|
||||
|
||||
$thirdpartyid = $objectemail->fk_soc;
|
||||
$contactid = $objectemail->fk_socpeople;
|
||||
$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
|
||||
$projectstatic->id=0;
|
||||
if ($projectid > 0)
|
||||
if (empty($contactid)) // Try to find contact using email
|
||||
{
|
||||
$result = $projectstatic->fetch($projectid);
|
||||
if ($result <= 0) $projectstatic->id = 0;
|
||||
}
|
||||
// Contact
|
||||
$contactstatic->id=0;
|
||||
if ($contactid > 0)
|
||||
{
|
||||
$result = $contactstatic->fetch($contactid);
|
||||
if ($result <= 0) $contactstatic->id = 0;
|
||||
}
|
||||
else // Try to find contact using email
|
||||
{
|
||||
$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);
|
||||
$result = $contactstatic->fetch(0, null, '', $from);
|
||||
if ($result > 0)
|
||||
{
|
||||
$contactid = $contactstatic->id;
|
||||
$contactfoundby = 'email of contact ('.$from.')';
|
||||
if ($contactstatic->fk_soc > 0)
|
||||
{
|
||||
$result = $thirdpartystatic->fetch($contactstatic->fk_soc);
|
||||
if ($result > 0)
|
||||
{
|
||||
$thirdpartyid = $thirdpartystatic->id;
|
||||
$thirdpartyfoundby = 'email of contact ('.$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)
|
||||
{
|
||||
if ($errorforactions) break;
|
||||
if (empty($operation['status'])) continue;
|
||||
|
||||
// Make Operation
|
||||
if ($operation['type'] == 'recordevent')
|
||||
|
||||
// Search and create thirdparty
|
||||
if ($operation['type'] == 'searchandcreatethirdparty')
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
// Create event
|
||||
elseif ($operation['type'] == 'recordevent')
|
||||
{
|
||||
$actioncode = 'EMAIL_IN';
|
||||
|
||||
@ -942,7 +1088,7 @@ class EmailCollector extends CommonObject
|
||||
$actioncomm->code = 'AC_'.$actioncode;
|
||||
$actioncomm->label = $langs->trans("EmailReceived").' - '.$langs->trans("From").' '.$from;
|
||||
$actioncomm->note = $messagetext;
|
||||
$actioncomm->fk_project = 0;
|
||||
$actioncomm->fk_project = $projectstatic->id;
|
||||
$actioncomm->datep = $date;
|
||||
$actioncomm->datef = $date;
|
||||
$actioncomm->percentage = -1; // Not applicable
|
||||
@ -950,7 +1096,7 @@ class EmailCollector extends CommonObject
|
||||
$actioncomm->contactid = $contactstatic->id;
|
||||
$actioncomm->authorid = $user->id; // User saving 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_from = $fromstring;
|
||||
$actioncomm->email_sender= $sender;
|
||||
@ -960,63 +1106,169 @@ class EmailCollector extends CommonObject
|
||||
$actioncomm->email_subject = $subject;
|
||||
$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->elementtype = $fk_element_type;
|
||||
|
||||
//$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++;
|
||||
$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)
|
||||
{
|
||||
$nbactiondone++;
|
||||
$nbactiondoneforemail++;
|
||||
}
|
||||
}
|
||||
|
||||
// Move email
|
||||
if (! $errorforactions && $targetdir)
|
||||
// Error for email or not ?
|
||||
if (! $errorforactions)
|
||||
{
|
||||
dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG);
|
||||
$res = imap_mail_move($connection, $imapemail, $targetdir, 0);
|
||||
if ($res == false) {
|
||||
$error++;
|
||||
$this->error = imap_last_error();
|
||||
dol_syslog(imap_last_error());
|
||||
if ($targetdir)
|
||||
{
|
||||
dol_syslog("EmailCollector::doCollectOneCollector move message ".$imapemail." to ".$connectstringtarget, LOG_DEBUG);
|
||||
$res = imap_mail_move($connection, $imapemail, $targetdir, 0);
|
||||
if ($res == false) {
|
||||
$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++;
|
||||
|
||||
unset($objectemail);
|
||||
|
||||
$this->db->commit();
|
||||
unset($projectstatic);
|
||||
unset($thirdpartystatic);
|
||||
unset($contactstatic);
|
||||
}
|
||||
|
||||
$this->output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbactiondone);
|
||||
$output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->output=$langs->trans('NoNewEmailToProcess');
|
||||
$output=$langs->trans('NoNewEmailToProcess');
|
||||
}
|
||||
|
||||
imap_expunge($connection); // To validate any move
|
||||
@ -1024,7 +1276,8 @@ class EmailCollector extends CommonObject
|
||||
imap_close($connection);
|
||||
|
||||
$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->update($user);
|
||||
|
||||
|
||||
@ -89,9 +89,9 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'29','Group
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'31','Personne morale de droit étranger, immatriculée au RCS');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'32','Personne morale de droit étranger, non immatriculée au RCS');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'35','Régime auto-entrepreneur');
|
||||
|
||||
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'41','Etablissement public ou régie à caractère industriel ou commercial');
|
||||
|
||||
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'51','Société coopérative commerciale particulière');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'52','Société en nom collectif');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'53','Société en commandite');
|
||||
@ -108,18 +108,18 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'63','Soci
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'64','Société non commerciale d assurances');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'65','Société civile');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'69','Personnes de droit privé inscrites au RCS');
|
||||
|
||||
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'71','Administration de l état');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'72','Collectivité territoriale');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'73','Etablissement public administratif');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'74','Personne morale de droit public administratif');
|
||||
|
||||
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'81','Organisme gérant régime de protection social à adhésion obligatoire');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'82','Organisme mutualiste');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'83','Comité d entreprise');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'84','Organisme professionnel');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'85','Organisme de retraite à adhésion non obligatoire');
|
||||
|
||||
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'91','Syndicat de propriétaires');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'92','Association loi 1901 ou assimilé');
|
||||
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'93','Fondation');
|
||||
@ -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, '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
|
||||
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);
|
||||
@ -313,4 +324,5 @@ 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, '17802', 'Asociación General', 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, '17805', 'Sociedad Anónima', 1);
|
||||
INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17805', 'Sociedad Anónima', 1);
|
||||
|
||||
|
||||
@ -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_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;
|
||||
|
||||
|
||||
@ -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_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 fk_projet integer DEFAULT NULL after amount;
|
||||
|
||||
@ -142,26 +152,26 @@ UPDATE llx_holiday SET ref = rowid WHERE ref IS NULL;
|
||||
|
||||
CREATE TABLE llx_emailcollector_emailcollector(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
entity integer DEFAULT 1 NOT NULL,
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
entity integer DEFAULT 1 NOT NULL,
|
||||
ref varchar(128) NOT NULL,
|
||||
label varchar(255),
|
||||
label varchar(255),
|
||||
description text,
|
||||
host varchar(255),
|
||||
user varchar(128),
|
||||
host varchar(255),
|
||||
user varchar(128),
|
||||
password varchar(128),
|
||||
source_directory varchar(255) NOT NULL,
|
||||
target_directory varchar(255),
|
||||
datelastresult datetime,
|
||||
codelastresult varchar(16),
|
||||
datelastresult datetime,
|
||||
codelastresult varchar(16),
|
||||
lastresult varchar(255),
|
||||
note_public text,
|
||||
note_private text,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
note_public text,
|
||||
note_private text,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
status integer NOT NULL
|
||||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
@ -174,28 +184,28 @@ CREATE TABLE llx_emailcollector_emailcollectoraction(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
fk_emailcollector INTEGER NOT NULL,
|
||||
type varchar(128) NOT NULL,
|
||||
actionparam varchar(255) NULL,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
type varchar(128) NOT NULL,
|
||||
actionparam varchar(255) NULL,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
status integer NOT NULL
|
||||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
|
||||
CREATE TABLE llx_emailcollector_emailcollectorfilter(
|
||||
-- BEGIN MODULEBUILDER FIELDS
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
|
||||
fk_emailcollector INTEGER NOT NULL,
|
||||
type varchar(128) NOT NULL,
|
||||
rulevalue varchar(255) NULL,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
type varchar(128) NOT NULL,
|
||||
rulevalue varchar(255) NULL,
|
||||
date_creation datetime NOT NULL,
|
||||
tms timestamp NOT NULL,
|
||||
fk_user_creat integer NOT NULL,
|
||||
fk_user_modif integer,
|
||||
import_key varchar(14),
|
||||
status integer NOT NULL
|
||||
-- END MODULEBUILDER FIELDS
|
||||
) ENGINE=innodb;
|
||||
|
||||
@ -1833,7 +1833,7 @@ EmailCollectorConfirmCollectTitle=Email collect confirmation
|
||||
EmailCollectorConfirmCollect=Do you want to run the collect for this collector now ?
|
||||
NoNewEmailToProcess=No new email (matching filters) to process
|
||||
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
|
||||
CreateLeadAndThirdParty=Create lead (and thirdparty if necessary)
|
||||
CodeLastResult=Result code of last collect
|
||||
|
||||
@ -431,4 +431,4 @@ SaleRepresentativeLogin=Login of sales representative
|
||||
SaleRepresentativeFirstname=First 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.
|
||||
NewCustomerSupplierCodeProposed=New customer or vendor code suggested on duplicate code
|
||||
NewCustomerSupplierCodeProposed=Customer or vendor code already used, a new code is suggested
|
||||
|
||||
@ -244,6 +244,9 @@ YourPasswordHasBeenReset=Your password has been reset successfully
|
||||
ApplicantIpAddress=IP address of applicant
|
||||
SMSSentTo=SMS sent to %s
|
||||
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 #####
|
||||
ExportsArea=Exports area
|
||||
|
||||
@ -184,6 +184,7 @@ ProjectsWithThisUserAsContact=Projects with this user as contact
|
||||
TasksWithThisUserAsContact=Tasks assigned to this user
|
||||
ResourceNotAssignedToProject=Not assigned to project
|
||||
ResourceNotAssignedToTheTask=Not assigned to the task
|
||||
NoUserAssignedToTheProject=No users assigned to this project
|
||||
TimeSpentBy=Time spent by
|
||||
TasksAssignedTo=Tasks assigned to
|
||||
AssignTaskToMe=Assign task to me
|
||||
@ -232,3 +233,4 @@ DontHaveTheValidateStatus=The project %s must be open to be closed
|
||||
RecordsClosed=%s project(s) closed
|
||||
SendProjectRef=Information project %s
|
||||
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
|
||||
@ -179,6 +179,10 @@ class Project extends CommonObject
|
||||
|
||||
$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
|
||||
if (!trim($this->ref))
|
||||
{
|
||||
@ -193,6 +197,7 @@ class Project extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create project
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet (";
|
||||
@ -211,6 +216,8 @@ class Project extends CommonObject
|
||||
$sql.= ", opp_amount";
|
||||
$sql.= ", budget_amount";
|
||||
$sql.= ", bill_time";
|
||||
$sql.= ", note_private";
|
||||
$sql.= ", note_public";
|
||||
$sql.= ", entity";
|
||||
$sql.= ") VALUES (";
|
||||
$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->budget_amount,'') ? price2num($this->budget_amount) : 'null');
|
||||
$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.= ")";
|
||||
|
||||
|
||||
@ -177,7 +177,7 @@ class ProjectStats extends Stats
|
||||
if (! empty($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) {
|
||||
$sqlwhere_str = ' WHERE ' . implode(' AND ', $sqlwhere);
|
||||
|
||||
@ -246,7 +246,18 @@ if ($action == 'createtask' && $user->rights->projet->creer)
|
||||
}
|
||||
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
|
||||
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 '</td></tr>';
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
* Copyright (C) 2015-2018 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.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
|
||||
* 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'));
|
||||
$object->birth = $birth;
|
||||
$object->admin = GETPOST("admin", 'alpha');
|
||||
$object->address = GETPOST('address', 'alpha');
|
||||
$object->address = GETPOST('address', 'alphanohtml');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
@ -341,7 +342,7 @@ if (empty($reshook)) {
|
||||
$object->pass = GETPOST("password",'none');
|
||||
$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
|
||||
$object->address = GETPOST('address', 'alpha');
|
||||
$object->address = GETPOST('address', 'alphanohtml');
|
||||
$object->zip = GETPOST('zipcode', 'alpha');
|
||||
$object->town = GETPOST('town', 'alpha');
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
@ -2137,7 +2138,16 @@ else
|
||||
// Employee
|
||||
print '<tr>';
|
||||
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>';
|
||||
|
||||
// Hierarchy
|
||||
@ -2341,7 +2351,12 @@ else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ColorUser").'</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>';
|
||||
}
|
||||
|
||||
@ -2364,7 +2379,12 @@ else
|
||||
foreach ($cats as $cat) {
|
||||
$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>";
|
||||
}
|
||||
|
||||
@ -2447,7 +2467,12 @@ else
|
||||
print $hookmanager->resPrint;
|
||||
if (empty($reshook))
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
if ($caneditfield)
|
||||
{
|
||||
print $object->showOptionals($extrafields,'edit');
|
||||
}else{
|
||||
print $object->showOptionals($extrafields,'view');
|
||||
}
|
||||
}
|
||||
|
||||
// Signature
|
||||
@ -2496,7 +2521,11 @@ else
|
||||
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
|
||||
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 "</tr>\n";
|
||||
|
||||
@ -2506,7 +2535,12 @@ else
|
||||
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classthm');
|
||||
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 "</tr>\n";
|
||||
|
||||
@ -2521,21 +2555,36 @@ else
|
||||
// Weeklyhours
|
||||
print '<tr><td>'.$langs->trans("WeeklyHours").'</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 "</tr>\n";
|
||||
|
||||
// Date employment
|
||||
print '<tr><td>'.$langs->trans("DateEmployment").'</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 "</tr>\n";
|
||||
|
||||
// Date employmentEnd
|
||||
print '<tr><td>'.$langs->trans("DateEmploymentEnd").'</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 "</tr>\n";
|
||||
|
||||
@ -2543,7 +2592,12 @@ else
|
||||
// Date birth
|
||||
print '<tr><td>'.$langs->trans("DateToBirth").'</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 "</tr>\n";
|
||||
|
||||
|
||||
@ -764,7 +764,7 @@ class User extends CommonObject
|
||||
// Recuperation des droits utilisateurs + recuperation des droits groupes
|
||||
|
||||
// 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.= ", ".MAIN_DB_PREFIX."rights_def as r";
|
||||
$sql.= " WHERE r.id = ur.fk_id";
|
||||
@ -818,7 +818,7 @@ class User extends CommonObject
|
||||
}
|
||||
|
||||
// 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.= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."rights_def as r";
|
||||
|
||||
@ -261,15 +261,18 @@ print '<div class="div-table-responsive">';
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
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">';
|
||||
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.'&action=addrights&entity='.$entity.'&module=allmodules">'.$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.'&action=delrights&entity='.$entity.'&module=allmodules">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
if ($caneditperms)
|
||||
{
|
||||
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.'&action=addrights&entity='.$entity.'&module=allmodules">'.$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.'&action=delrights&entity='.$entity.'&module=allmodules">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
}
|
||||
print '<td align="center" width="24"> </td>';
|
||||
}
|
||||
print '<td align="center" width="24"> </td>';
|
||||
print '<td>'.$langs->trans("Permissions").'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
@ -310,21 +313,31 @@ if ($result)
|
||||
print '<tr class="oddeven trforbreak">';
|
||||
print '<td class="maxwidthonsmartphone tdoverflowonsmartphone">'.img_object('',$picto,'class="pictoobjectwidth"').' '.$objMod->getName();
|
||||
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.'&action=addrights&entity='.$entity.'&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.'&action=delrights&entity='.$entity.'&module='.$obj->module.'">'.$langs->trans("None")."</a>";
|
||||
if ($caneditperms)
|
||||
{
|
||||
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.'&action=addrights&entity='.$entity.'&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.'&action=delrights&entity='.$entity.'&module='.$obj->module.'">'.$langs->trans("None")."</a>";
|
||||
print '</td>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($caneditperms)
|
||||
{
|
||||
print '<td></td>';
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
print '<td colspan="2"> </td>';
|
||||
print '</tr>'."\n";
|
||||
}
|
||||
|
||||
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>';
|
||||
|
||||
// Permission and tick
|
||||
@ -383,6 +396,7 @@ if ($result)
|
||||
print '<td> </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)));
|
||||
print '<td class="maxwidthonsmartphone">'.$permlabel.'</td>';
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
||||
|
||||
$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)))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user