diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index aeaf19f8471..b7f2a002105 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -602,6 +602,29 @@ if (empty($reshook))
}
}
+ // Action confirmation validation
+ if ($action == 'confirm_settodraft' && $confirm == 'yes')
+ {
+ if ($object->id > 0)
+ {
+ $result = $object->setStatut(0);
+ if ($result > 0)
+ {
+ //setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
+ header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
+ exit;
+ }
+ else
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+ }
+
// Resend
if ($action == 'confirm_reset' && $confirm == 'yes')
{
@@ -707,7 +730,7 @@ if ($action == 'create')
print '
';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor('body',$_POST['body'],'',320,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,'90%');
+ $doleditor=new DolEditor('body',$_POST['body'],'',600,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,'90%');
$doleditor->Create();
print '
';
@@ -727,7 +750,12 @@ else
dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email');
- // Confirmation de la validation du mailing
+ // Confirmation back to draft
+ if ($action == 'settodraft')
+ {
+ print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("SetToDraft"),$langs->trans("ConfirmUnvalidateEmailing"),"confirm_settodraft",'','',1);
+ }
+ // Confirmation validation of mailing
if ($action == 'valid')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valid",'','',1);
@@ -900,10 +928,15 @@ else
* Boutons d'action
*/
- if (GETPOST("cancel") || $confirm=='no' || $action == '' || in_array($action,array('valid','delete','sendall','clone')))
+ if (GETPOST("cancel") || $confirm=='no' || $action == '' || in_array($action,array('settodraft', 'valid','delete','sendall','clone')))
{
print "\n\n\n";
+ if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id))
+ {
+ print '
'.$langs->trans("SetToDraft").'';
+ }
+
if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer)
{
print '
'.$langs->trans("EditMailing").'';
@@ -1065,7 +1098,7 @@ else
$readonly=1;
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor('body',$object->body,'',320,'dolibarr_mailings','',false,true,empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1,20,120,$readonly);
+ $doleditor=new DolEditor('body',$object->body,'',600,'dolibarr_mailings','',false,true,empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1,20,120,$readonly);
$doleditor->Create();
}
else print dol_htmlentitiesbr($object->body);
@@ -1212,7 +1245,7 @@ else
print '
';
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor('body',$object->body,'',320,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,'90%');
+ $doleditor=new DolEditor('body',$object->body,'',600,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,'90%');
$doleditor->Create();
print '
';
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index e104db4dcda..470ee2a4ec1 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -533,7 +533,7 @@ if ($object->fetch($id) >= 0)
print '
';
if (empty($obj->source_id) || empty($obj->source_type))
{
- print $obj->source_url; // For backward compatibility
+ print empty($obj->source_url)?'':$obj->source_url; // For backward compatibility
}
else
{
diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index dc39c2e9399..b0dff81332c 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -601,35 +601,38 @@ class Mailing extends CommonObject
if ($mode == 2)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
- if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
- if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
- if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
+ if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
+ if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
+ if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
if ($mode == 3)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
- if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
- if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
- if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
+ if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
+ if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
+ if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
if ($mode == 4)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
- if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
- if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
- if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
+ if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
+ if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
+ if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
if ($mode == 5)
{
- if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
- if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut4');
- if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
- if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
+ if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
+ if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
+ if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
+ if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
+ }
+ if ($mode == 6)
+ {
+ if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
+ if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
+ if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
+ if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
-
-
-
-
}
}
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index b0801c817aa..2d6fae37b98 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -174,7 +174,7 @@ if ($result)
{
print ' | ';
$nbemail = $obj->nbemail;
- if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
+ /*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail)
{
$text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB);
print $form->textwithpicto($nbemail,$text,1,'warning');
@@ -182,7 +182,8 @@ if ($result)
else
{
print $nbemail;
- }
+ }*/
+ print $nbemail;
print ' | ';
}
// Last send
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index f332cb65203..54c8bf1bac1 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -804,14 +804,14 @@ if (empty($reshook))
$line->fk_parent_line = $fk_parent_line;
$line->subprice =-$line->subprice; // invert price for object
- $line->pa_ht = -$line->pa_ht;
+ $line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here
$line->total_ht=-$line->total_ht;
$line->total_tva=-$line->total_tva;
$line->total_ttc=-$line->total_ttc;
$line->total_localtax1=-$line->total_localtax1;
$line->total_localtax2=-$line->total_localtax2;
- $result = $line->insert();
+ $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
$object->lines[] = $line; // insert new line in current object
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 72e81fd252e..73a4a5a85ab 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1277,7 +1277,7 @@ class Facture extends CommonInvoice
{
$this->lines=array();
- $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
+ $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
$sql.= ' l.situation_percent, l.fk_prev_id,';
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql.= ' l.rang, l.special_code,';
@@ -1304,6 +1304,7 @@ class Facture extends CommonInvoice
$line->id = $objp->rowid;
$line->rowid = $objp->rowid; // deprecated
+ $line->fk_facture = $objp->fk_facture;
$line->label = $objp->custom_label; // deprecated
$line->desc = $objp->description; // Description line
$line->description = $objp->description; // Description line
@@ -1558,6 +1559,18 @@ class Facture extends CommonInvoice
$facligne->rang=-1;
$facligne->info_bits=2;
+ // Get buy/cost price of invoice that is source of discount
+ if ($remise->fk_facture_source > 0)
+ {
+ $srcinvoice=new Facture($this->db);
+ $srcinvoice->fetch($remise->fk_facture_source);
+ $totalcostpriceofinvoice=0;
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; // TODO Move this into commonobject
+ $formmargin=new FormMargin($this->db);
+ $arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false);
+ $facligne->pa_ht = $arraytmp['pa_total'];
+ }
+
$facligne->total_ht = -$remise->amount_ht;
$facligne->total_tva = -$remise->amount_tva;
$facligne->total_ttc = -$remise->amount_ttc;
@@ -4295,10 +4308,11 @@ class FactureLigne extends CommonInvoiceLine
/**
* Insert line into database
*
- * @param int $notrigger 1 no triggers
- * @return int <0 if KO, >0 if OK
+ * @param int $notrigger 1 no triggers
+ * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another
+ * @return int <0 if KO, >0 if OK
*/
- function insert($notrigger=0)
+ function insert($notrigger=0, $noerrorifdiscountalreadylinked=0)
{
global $langs,$user,$conf;
@@ -4445,13 +4459,16 @@ class FactureLigne extends CommonInvoiceLine
// Check if discount was found
if ($result > 0)
{
- // Check if discount not already affected to another invoice
- if ($discount->fk_facture)
+ // Check if discount not already affected to another invoice
+ if ($discount->fk_facture_line > 0)
{
- $this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id);
- dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
- $this->db->rollback();
- return -3;
+ if (empty($noerrorifdiscountalreadylinked))
+ {
+ $this->error=$langs->trans("ErrorDiscountAlreadyUsed",$discount->id);
+ dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -3;
+ }
}
else
{
diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php
index 3882d2ebca3..e97263ebf00 100644
--- a/htdocs/contact/agenda.php
+++ b/htdocs/contact/agenda.php
@@ -81,7 +81,7 @@ if (GETPOST('actioncode','array'))
}
else
{
- $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE));
+ $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
$search_agenda_label=GETPOST('search_agenda_label');
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 37bd3078c7d..7d95da69aef 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -714,6 +714,11 @@ else
print ' ';
print '
';
}
+ else
+ {
+ print ' ';
+ print '
';
+ }
print '
';
print "";
@@ -997,7 +1002,7 @@ else
print '