Skip to content

Commit

Permalink
Merge branch '8.0' of git@github.com:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
Conflicts:
	htdocs/commande/class/commande.class.php
	htdocs/core/lib/security.lib.php
	htdocs/modulebuilder/template/myobject_card.php
  • Loading branch information
eldy committed Oct 30, 2018
2 parents 7a268d8 + afe6157 commit 68f6ebd
Show file tree
Hide file tree
Showing 15 changed files with 387 additions and 382 deletions.
62 changes: 39 additions & 23 deletions htdocs/adherents/card.php
Expand Up @@ -644,19 +644,27 @@
$msg = $arraydefaultmessage->content;
}

$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
if (empty($labeltouse) || (int)$labeltouse === -1) {
//fallback on the old configuration.
setEventMessages('WarningMandatorySetupNotComplete', [], 'errors');
$error++;
}else{
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);

$moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";

$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
if ($result < 0)
{
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}

$moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";

$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
if ($result < 0)
{
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
else
Expand Down Expand Up @@ -718,20 +726,28 @@
$msg = $arraydefaultmessage->content;
}

$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);
if (empty($labeltouse) || (int)$labeltouse === -1) {
//fallback on the old configuration.
setEventMessages('WarningMandatorySetupNotComplete', [], 'errors');
$error++;
}else{
$substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs);

$moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";

$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
if ($result < 0)
{
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

$moreinheader='X-Dolibarr-Info: send_an_email by adherents/card.php'."\r\n";

$result=$object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
}
if ($result < 0)
{
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions htdocs/adherents/subscription/list.php
Expand Up @@ -40,7 +40,7 @@
$search_amount=GETPOST('search_amount','alpha');
$optioncss = GETPOST('optioncss','alpha');

$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
$date_select=GETPOST("date_select",'alpha');

$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
Expand Down Expand Up @@ -126,7 +126,8 @@
$sql.= " AND d.entity IN (".getEntity('adherent').")";
if (isset($date_select) && $date_select != '')
{
$sql.= " AND c.dateadh LIKE '".$date_select."%'";
$sql.= " AND c.dateadh >= '".$date_select."-01-01 00:00:00'";
$sql.= " AND c.dateadh < '".($date_select+1)."-01-01 00:00:00'";
}
if ($search_ref)
{
Expand Down
22 changes: 13 additions & 9 deletions htdocs/commande/class/commande.class.php
Expand Up @@ -108,8 +108,11 @@ class Commande extends CommonOrder
*/
public $billed; // billed or not

public $brouillon;
public $cond_reglement_code;
/**
* @var int Draft Status of the order
*/
public $brouillon;
public $cond_reglement_code;

/**
* @var int ID
Expand Down Expand Up @@ -155,7 +158,7 @@ class Commande extends CommonOrder
public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
public $demand_reason_code;
public $date; // Date commande

/**
* @deprecated
* @see date
Expand Down Expand Up @@ -274,11 +277,11 @@ function getNextNumRef($soc)
$mybool|=@include_once $dir.$file;
}

if (! $mybool)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}
if ($mybool === false)
{
dol_print_error('',"Failed to include file ".$file);
return '';
}

$obj = new $classname();
$numref = $obj->getNextValue($soc,$this);
Expand Down Expand Up @@ -448,6 +451,7 @@ function valid($user, $idwarehouse=0, $notrigger=0)
{
$this->ref = $num;
$this->statut = self::STATUS_VALIDATED;
$this->brouillon = 0;
}

if (! $error)
Expand Down Expand Up @@ -3774,7 +3778,7 @@ function getLinesArray()
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @param null|array $moreparams Array to provide more information
* @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Expand Down
36 changes: 20 additions & 16 deletions htdocs/compta/facture/card.php
Expand Up @@ -93,11 +93,6 @@
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));

// Security check
$fieldid = (! empty($ref) ? 'facnumber' : 'rowid');
if ($user->societe_id) $socid = $user->societe_id;
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);

// Nombre de ligne pour choix de produit/service predefinis
$NBLINES = 4;

Expand All @@ -118,6 +113,12 @@
$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

// Security check
$fieldid = (! empty($ref) ? 'facnumber' : 'rowid');
if ($user->societe_id) $socid = $user->societe_id;
$isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft);


/*
* Actions
Expand Down Expand Up @@ -178,7 +179,7 @@
}

// Delete invoice
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) {
else if ($action == 'confirm_delete' && $confirm == 'yes') {
$result = $object->fetch($id);
$object->fetch_thirdparty();

Expand All @@ -191,7 +192,10 @@
$qualified_for_stock_change = $object->hasProductsOrServices(1);
}

if ($object->is_erasable())
$isErasable=$object->is_erasable();

if (($user->rights->facture->supprimer && $isErasable > 0)
|| ($user->rights->facture->creer && $isErasable == 1))
{
$result = $object->delete($user, 0, $idwarehouse);
if ($result > 0) {
Expand Down Expand Up @@ -2981,8 +2985,8 @@
print $desc;
print '</div></div>';
}


if (empty($origin))
{
if ($socid > 0)
Expand Down Expand Up @@ -3057,7 +3061,7 @@

print '</div>';


if(!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
{
// Add auto select default document model
Expand All @@ -3069,7 +3073,7 @@
$curent = !empty($conf->global->{$thisTypeConfName})?$conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
$jsListType.=(!empty($jsListType)?',':'').'"'.$type.'":"'.$curent.'"';
}

print '<script type="text/javascript" language="javascript">
$(document).ready(function() {
var listType = {'.$jsListType.'};
Expand All @@ -3089,9 +3093,9 @@
});
</script>';
}



print '</td></tr>';

if ($socid > 0)
Expand Down Expand Up @@ -4847,9 +4851,9 @@ function js_recalculate_revenuestamp(){
}

// Delete
if ($user->rights->facture->supprimer)
$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)
{
$isErasable = $object->is_erasable();
//var_dump($isErasable);
if ($isErasable == -4) {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans("DisabledBecausePayments") . '">' . $langs->trans('Delete') . '</a></div>';
Expand Down
6 changes: 3 additions & 3 deletions htdocs/compta/facture/class/facture.class.php
Expand Up @@ -251,7 +251,7 @@ class Facture extends CommonInvoice
* If paid partially, $this->close_code can be:
* - CLOSECODE_DISCOUNTVAT
* - CLOSECODE_BADDEBT
* If paid completelly, this->close_code will be null
* If paid completely, this->close_code will be null
*/
const STATUS_CLOSED = 2;

Expand Down Expand Up @@ -2442,7 +2442,7 @@ function validate($user, $force_number='', $idwarehouse=0, $notrigger=0)
}
}

// Set new ref and define current statut
// Set new ref and define current status
if (! $error)
{
$this->ref = $num;
Expand Down Expand Up @@ -4950,7 +4950,7 @@ function get_prev_progress($invoiceid, $include_credit_note=true)
if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") {
return 0;
} else {
// If invoice is a not a situation invoice, this->fk_prev_id is used for something else
// If invoice is not a situation invoice, this->fk_prev_id is used for something else
$tmpinvoice=new Facture($this->db);
$tmpinvoice->fetch($invoiceid);
if ($tmpinvoice->type != Facture::TYPE_SITUATION) return 0;
Expand Down
5 changes: 3 additions & 2 deletions htdocs/core/class/commoninvoice.class.php
Expand Up @@ -329,12 +329,13 @@ function getListOfPayments($filtertype='')
/**
* Return if an invoice can be deleted
* Rule is:
* If invoice is draft and has a temporary ref -> yes
* If invoice is draft and has a temporary ref -> yes (1)
* If hidden option INVOICE_CAN_NEVER_BE_REMOVED is on -> no (0)
* If invoice is dispatched in bookkeeping -> no (-1)
* If invoice has a definitive ref, is not last and INVOICE_CAN_ALWAYS_BE_REMOVED off -> no (-2)
* If invoice not last in a cycle -> no (-3)
* If there is payment -> no (-4)
* Otherwise -> yes (2)
*
* @return int <=0 if no, >0 if yes
*/
Expand Down Expand Up @@ -383,7 +384,7 @@ function is_erasable()
// Test if there is at least one payment. If yes, refuse to delete.
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;

return 1;
return 2;
}

/**
Expand Down
20 changes: 10 additions & 10 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -6572,15 +6572,15 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
/**
* Get formated error messages to output (Used to show messages on html output).
*
* @param string $mesgstring Error message
* @param string $mesgstring Error message
* @param array $mesgarray Error messages array
* @param int $keepembedded Set to 1 in error message must be kept embedded into its html place (this disable jnotify)
* @return string Return html output
*
* @see dol_print_error
* @see dol_htmloutput_mesg
*/
function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
function get_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
{
return get_htmloutput_mesg($mesgstring, $mesgarray,'error',$keepembedded);
}
Expand All @@ -6590,15 +6590,15 @@ function get_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
*
* @param string $mesgstring Message string or message key
* @param string[] $mesgarray Array of message strings or message keys
* @param string $style Which style to use ('ok', 'warning', 'error')
* @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
* @return void
* @param string $style Which style to use ('ok', 'warning', 'error')
* @param int $keepembedded Set to 1 if message must be kept embedded into its html place (this disable jnotify)
* @return void
*
* @see dol_print_error
* @see dol_htmloutput_errors
* @see setEventMessages
* @see dol_print_error
* @see dol_htmloutput_errors
* @see setEventMessages
*/
function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepembedded=0)
function dol_htmloutput_mesg($mesgstring = '',$mesgarray = array(), $style = 'ok', $keepembedded=0)
{
if (empty($mesgstring) && (! is_array($mesgarray) || count($mesgarray) == 0)) return;

Expand Down Expand Up @@ -6652,7 +6652,7 @@ function dol_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
* @see dol_print_error
* @see dol_htmloutput_mesg
*/
function dol_htmloutput_errors($mesgstring='', $mesgarray='', $keepembedded=0)
function dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
{
dol_htmloutput_mesg($mesgstring, $mesgarray, 'error', $keepembedded);
}
Expand Down

0 comments on commit 68f6ebd

Please sign in to comment.