diff --git a/ChangeLog b/ChangeLog
index 5377a690e1f..af001a3c0ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,23 +40,27 @@ For users:
- New: Add Maghreb regions and departments.
- New: A more responsive desgin for statistic box of home page.
- Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
-- New: [ task #1005 ] Adapting to Spanish legislation bill numbering.
-- New: [ task #1011 ] Now supplier order and invoice deal with payment terms and mode.
-- New: [ task #1014 ] Add option to recursivly add parent category.
-- New: [ task #1016 ] Can define a specific numbering for deposits.
-- New: [ task #918 ] Stock replenishment.
-- Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count.
-- New: Add pdf link into supplier invoice list and supplier order list.
-- New: Genrate auto the PDF for supplier invoice.
-- New: Add category into filter webservice thirdparty method getListOfThirdParties.
-- New: Allow to define margin or mark rate during quoting, ordering, invoicing.
-- New: User permissions on margin module.
-- New: Add ref supplier into muscadet model.
+- New: [ task #1005 ] Adapting to Spanish legislation bill numbering
+- New: [ task #1011 ] Now supplier order and invoice deal with payment terms and mode
+- New: [ task #1014 ] Add option to recursivly add parent category
+- New: [ task #1016 ] Can define a specific numbering for deposits
+- New: [ task #918 ] Stock replenishment
+- Fix: [ bug #992 ] Proforma invoices don't have a separated numeric count
+- New : Add pdf link into supplier invoice list and supplier order list
+- New : Genrate auto the PDF for supplier invoice
+- New : Add category into filter webservice thirdparty method getListOfThirdParties
+- New : Allow to define margin or mark rate during quoting, ordering, invoicing
+- New : User permissions on margin module
+- New : Add ref supplier into muscadet model
+- New : Add ability to copy contact address to clipboard
- New: Can use tag {mm} before {yy} even when there is a reset into numbering masks.
- New: [ task #1060 ] Register fields localtax(1|2)_type into details tables.
- New: [ task #923 ] Localtax support for ODT templates.
- New: [ task #90 ] Barcode search.
- New: Add hidden option MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS.
+- New: Can send an email from thirdparty card.
+- New: Can cancel holidays that were previously validated.
+- Fix: [bug #1022] correct margin calculation for credit notes.
For translators:
- Qual: Normalized sort order of all languages files with english reference files.
@@ -109,6 +113,8 @@ parameter. All methods addline in this case were modified to remove this paramet
4) Method ->classer_facturee() is deprecated. It must be replace with ->classifyBilled().
+5) Property ->tel on objects is now ->phone
+
***** ChangeLog for 3.4.1 compared to 3.4.0 *****
Fix: Display buying price on line edit when no supplier price is defined
diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php
index 34420ee0121..25139697955 100644
--- a/htdocs/adherents/admin/adherent_extrafields.php
+++ b/htdocs/adherents/admin/adherent_extrafields.php
@@ -50,7 +50,7 @@ if (!$user->admin) accessforbidden();
* Actions
*/
-require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php
index ce2787752a7..5fdd9ff2a39 100644
--- a/htdocs/adherents/admin/adherent_type_extrafields.php
+++ b/htdocs/adherents/admin/adherent_type_extrafields.php
@@ -51,7 +51,7 @@ if (!$user->admin) accessforbidden();
* Actions
*/
-require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 2dae974d9c1..255eb1533d9 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -564,7 +564,7 @@ class Adherent extends CommonObject
$lthirdparty->zip=$this->zip;
$lthirdparty->town=$this->town;
$lthirdparty->email=$this->email;
- $lthirdparty->tel=$this->phone;
+ $lthirdparty->phone=$this->phone;
$lthirdparty->state_id=$this->state_id;
$lthirdparty->country_id=$this->country_id;
$lthirdparty->country_id=$this->country_id;
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index e3bbe5b55a9..2648a8ae721 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -691,7 +691,7 @@ else
/* */
/* ************************************************************************** */
$object->canvas=$canvas;
- $object->state_id = GETPOST('departement_id', 'int');
+ $object->state_id = GETPOST('state_id', 'int');
// We set country_id, country_code and country for the selected country
$object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php
index a7763893bb5..64f793cc761 100644
--- a/htdocs/admin/agenda_extrafields.php
+++ b/htdocs/admin/agenda_extrafields.php
@@ -56,7 +56,7 @@ if (!$user->admin) accessforbidden();
* Actions
*/
-require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php
index d9be768461f..de10a5b8e4f 100644
--- a/htdocs/admin/confexped.php
+++ b/htdocs/admin/confexped.php
@@ -87,7 +87,7 @@ $h++;
if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
- $head[$h][1] = $langs->trans("Sending");
+ $head[$h][1] = $langs->trans("Shipment");
$h++;
}
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index d0d21e43e64..0e0008a54b7 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -210,7 +210,7 @@ $head[$h][1] = $langs->trans("Setup");
$h++;
$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
-$head[$h][1] = $langs->trans("Sending");
+$head[$h][1] = $langs->trans("Shipment");
$hselected=$h;
$h++;
@@ -225,7 +225,7 @@ dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
/*
* Expedition numbering model
- */
+ */
print_titre($langs->trans("SendingsNumberingModules"));
@@ -260,13 +260,13 @@ foreach ($dirmodels as $reldir)
require_once $dir.$file.'.php';
$module = new $file;
-
+
if ($module->isEnabled())
{
// Show modules according to features level
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-
+
$var=!$var;
print '
'.$module->nom."
\n";
print '
';
@@ -276,8 +276,8 @@ foreach ($dirmodels as $reldir)
// Show example of numbering module
print '
';
$tmp=$module->getExample();
- if (preg_match('/^Error/',$tmp)) {
- $langs->load("errors"); print '
'.$langs->trans($tmp).'
';
+ if (preg_match('/^Error/',$tmp)) {
+ $langs->load("errors"); print '
';
diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php
index 48189eb60f6..76d73133e0f 100644
--- a/htdocs/contact/vcard.php
+++ b/htdocs/contact/vcard.php
@@ -70,7 +70,7 @@ $v->setTitle($contact->poste);
if ($company->id)
{
$v->setURL($company->url, "WORK");
- if (! $contact->phone_pro) $v->setPhoneNumber($company->tel, "WORK;VOICE");
+ if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "WORK;VOICE");
if (! $contact->fax) $v->setPhoneNumber($company->fax, "WORK;FAX");
if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country_code, "WORK;POSTAL");
if ($company->email != $contact->email) $v->setEmail($company->email,'internet');
diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php
index 22b07448462..c50872beee4 100644
--- a/htdocs/contrat/admin/contract_extrafields.php
+++ b/htdocs/contrat/admin/contract_extrafields.php
@@ -54,7 +54,7 @@ if (!$user->admin) accessforbidden();
* Actions
*/
-require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
diff --git a/htdocs/core/admin_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php
similarity index 99%
rename from htdocs/core/admin_extrafields.inc.php
rename to htdocs/core/actions_extrafields.inc.php
index 0b608a1e736..4861ee6b856 100644
--- a/htdocs/core/admin_extrafields.inc.php
+++ b/htdocs/core/actions_extrafields.inc.php
@@ -17,7 +17,7 @@
*/
/**
- * \file htdocs/core/admin_extrafields.inc.php
+ * \file htdocs/core/actions_extrafields.inc.php
* \brief Code for actions on extrafields admin pages
*/
@@ -306,4 +306,4 @@ if ($action == 'delete')
}
}
-?>
+?>
\ No newline at end of file
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
new file mode 100644
index 00000000000..f13113487c1
--- /dev/null
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -0,0 +1,233 @@
+
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * \file htdocs/core/actions_sendmails.inc.php
+ * \brief Code for actions on sending mails from object page
+ */
+
+
+// TODO Include this include file into all class objects
+
+// $id must be defined
+// $actiontypecode must be defined
+
+
+/*
+ * Add file in email form
+ */
+if (GETPOST('addfile'))
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ // Set tmp user directory
+ $vardir=$conf->user->dir_output."/".$user->id;
+ $upload_dir_tmp = $vardir.'/temp';
+
+ dol_add_file_process($upload_dir_tmp,0,0);
+ $action='presend';
+}
+
+/*
+ * Remove file in email form
+ */
+if (! empty($_POST['removedfile']))
+{
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+
+ // Set tmp user directory
+ $vardir=$conf->user->dir_output."/".$user->id;
+ $upload_dir_tmp = $vardir.'/temp';
+
+ // TODO Delete only files that was uploaded from email form
+ dol_remove_file_process($_POST['removedfile'],0);
+ $action='presend';
+}
+
+/*
+ * Send mail
+ */
+if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
+{
+ $langs->load('mails');
+
+ $subject='';$actionmsg='';$actionmsg2='';
+
+ $result=$object->fetch($id);
+
+ $sendtosocid=0;
+ if (method_exists($object,"fetch_thirdparty") && $object->element != 'societe')
+ {
+ $result=$object->fetch_thirdparty();
+ $thirdparty=$object->thirdparty;
+ $sendtosocid=$thirdparty->id;
+ }
+ else if ($object->element == 'societe')
+ {
+ $thirdparty=$object;
+ $sendtosocid=$thirdparty->id;
+ }
+ else dol_print_error('','Use actions_sendmails.in.php for a type that is not supported');
+
+ if ($result > 0)
+ {
+ if ($_POST['sendto'])
+ {
+ // Recipient is provided into free text
+ $sendto = $_POST['sendto'];
+ $sendtoid = 0;
+ }
+ elseif ($_POST['receiver'] != '-1')
+ {
+ // Recipient was provided from combo list
+ if ($_POST['receiver'] == 'thirdparty') // Id of third party
+ {
+ $sendto = $thirdparty->email;
+ $sendtoid = 0;
+ }
+ else // Id du contact
+ {
+ $sendto = $thirdparty->contact_get_property($_POST['receiver'],'email');
+ $sendtoid = $_POST['receiver'];
+ }
+ }
+
+ if (dol_strlen($sendto))
+ {
+ $langs->load("commercial");
+
+ $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
+ $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>';
+ $message = $_POST['message'];
+ $sendtocc = $_POST['sendtocc'];
+ $deliveryreceipt = $_POST['deliveryreceipt'];
+
+ if ($action == 'send' || $action == 'relance')
+ {
+ if (dol_strlen($_POST['subject'])) $subject = $_POST['subject'];
+ $actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
+ if ($message)
+ {
+ $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n";
+ $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n";
+ $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n";
+ $actionmsg.=$message;
+ }
+ }
+
+ // Create form object
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ $formmail = new FormMail($db);
+
+ $attachedfiles=$formmail->get_attached_files();
+ $filepath = $attachedfiles['paths'];
+ $filename = $attachedfiles['names'];
+ $mimetype = $attachedfiles['mimes'];
+
+ // Send mail
+ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt,-1);
+ if ($mailfile->error)
+ {
+ $mesgs[]='
'.$mailfile->error.'
';
+ }
+ else
+ {
+ $result=$mailfile->sendfile();
+ if ($result)
+ {
+ $error=0;
+
+ // Initialisation donnees
+ $object->socid = $sendtosocid; // To link to a company
+ $object->sendtoid = $sendtoid; // To link to a contact/address
+ $object->actiontypecode = $actiontypecode;
+ $object->actionmsg = $actionmsg; // Long text
+ $object->actionmsg2 = $actionmsg2; // Short text
+ $object->fk_element = $object->id;
+ $object->elementtype = $object->element;
+
+ // Appel des triggers
+ include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ $interface=new Interfaces($db);
+ $result=$interface->run_triggers('COMPANY_SENTBYMAIL',$object,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
+ // Fin appel triggers
+
+ if ($error)
+ {
+ dol_print_error($db);
+ }
+ else
+ {
+ // Redirect here
+ // This avoid sending mail twice if going out and then back to page
+ $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
+ setEventMessage($mesg);
+ header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
+ exit;
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ $mesg='
';
+ if ($mailfile->error)
+ {
+ $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
+ $mesg.=' '.$mailfile->error;
+ }
+ else
+ {
+ $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
+ }
+ $mesg.='
';
+ dol_syslog('Recipient email is empty');
+ }*/
+ }
+ else
+ {
+ $langs->load("errors");
+ setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")),'warnings');
+ dol_syslog('Try to send email with no recipiend defined', LOG_WARNING);
+ $action = 'presend';
+ }
+ }
+ else
+ {
+ $langs->load("other");
+ setEventMessage($langs->trans('ErrorFailedToReadEntity',$object->element),'errors');
+ dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
+ $action = 'presend';
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php
index 1f4b6acb6fb..294458d2352 100644
--- a/htdocs/core/ajax/ziptown.php
+++ b/htdocs/core/ajax/ziptown.php
@@ -116,7 +116,6 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
$row_array['value'] = $row['town'];
$row_array['zipcode'] = $row['zip'];
}
- $row_array['departement_id'] = $row['fk_county']; // deprecated
$row_array['selectcountry_id'] = $row['fk_country'];
$row_array['state_id'] = $row['fk_county'];
diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php
index b0b9ad39317..2e0b41f9451 100644
--- a/htdocs/core/boxes/box_members.php
+++ b/htdocs/core/boxes/box_members.php
@@ -79,7 +79,7 @@ class box_members extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers",$max));
- if ($user->rights->societe->lire)
+ if ($user->rights->adherent->lire)
{
$sql = "SELECT a.rowid, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,";
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 6d89e18c77d..c6413b4beae 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -451,9 +451,10 @@ abstract class CommonObject
* @param string $source 'internal', 'external' or 'all'
* @param string $order Sort order by : 'code' or 'rowid'
* @param string $option 0=Return array id->label, 1=Return array code->label
+ * @param string $activeonly 0=all type of contact, 1=only the active
* @return array Array list of type of contacts (id->label if option=0, code->label if option=1)
*/
- function liste_type_contact($source='internal', $order='code', $option=0)
+ function liste_type_contact($source='internal', $order='code', $option=0, $activeonly=0)
{
global $langs;
@@ -461,6 +462,9 @@ abstract class CommonObject
$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle";
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
$sql.= " WHERE tc.element='".$this->element."'";
+ if ($activeonly == 1)
+ $sql.= " AND tc.active=1"; // only the active type
+
if (! empty($source)) $sql.= " AND tc.source='".$source."'";
$sql.= " ORDER by tc.".$order;
@@ -2617,6 +2621,7 @@ abstract class CommonObject
}
}
+
/* This is to show add lines */
@@ -3129,53 +3134,80 @@ abstract class CommonObject
// calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
+ $pa = $line->qty * $line->pa_ht;
+ $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit
- $marginInfos['pa_products'] += $line->pa_ht;// ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pv_products'] += $line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pa_total'] += $line->pa_ht;// ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100);
+ $marginInfos['pa_products'] += $pa;
+ $marginInfos['pv_products'] += $pv;
+ $marginInfos['pa_total'] += $pa;
+ $marginInfos['pv_total'] += $pv;
+ // if credit note, margin = -1 * (abs(selling_price) - buying_price)
+ if ($pv < 0)
+ $marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
+ else
+ $marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
- $marginInfos['pa_services'] += $line->pa_ht;// ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pv_services'] += $line->subprice * (1 - ($line->remise_percent / 100));
- $marginInfos['pa_total'] += $line->pa_ht;// ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pv_total'] += $line->subprice * (1 - $line->remise_percent / 100);
+ $marginInfos['pa_services'] += $pa;
+ $marginInfos['pv_services'] += $pv;
+ $marginInfos['pa_total'] += $pa;
+ $marginInfos['pv_total'] += $pv;
+ // if credit note, margin = -1 * (abs(selling_price) - buying_price)
+ if ($pv < 0)
+ $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
+ else
+ $marginInfos['margin_on_services'] += $pv - $pa;
}
elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
- $marginInfos['pa_total'] += $line->pa_ht;// ($line->pa_ht != 0)?$line->pa_ht:$line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pv_total'] += $line->subprice * (1 - ($line->remise_percent / 100));
+ $marginInfos['pa_total'] += $pa;
+ $marginInfos['pv_total'] += $pv;
}
}
else {
$type=$line->product_type?$line->product_type:$line->fk_product_type;
if ($type == 0) { // product
- $marginInfos['pa_products'] += $line->qty * $line->pa_ht;
- $marginInfos['pv_products'] += $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
- $marginInfos['pa_total'] += $line->qty * $line->pa_ht;
- $marginInfos['pv_total'] += $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
+ $pa = $line->qty * $line->pa_ht;
+ $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
+ $marginInfos['pa_products'] += $pa;
+ $marginInfos['pv_products'] += $pv;
+ $marginInfos['pa_total'] += $pa;
+ $marginInfos['pv_total'] += $pv;
+ // if credit note, margin = -1 * (abs(selling_price) - buying_price)
+ if ($pv < 0)
+ $marginInfos['margin_on_products'] += -1 * (abs($pv) - $pa);
+ else
+ $marginInfos['margin_on_products'] += $pv - $pa;
}
elseif ($type == 1) { // service
- $marginInfos['pa_services'] += $line->qty * $line->pa_ht;
- $marginInfos['pv_services'] += $line->qty * $line->subprice * (1 - ($line->remise_percent / 100));
- $marginInfos['pa_total'] += $line->qty * $line->pa_ht;
- $marginInfos['pv_total'] += $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
+ $pa = $line->qty * $line->pa_ht;
+ $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100);
+ $marginInfos['pa_services'] += $pa;
+ $marginInfos['pv_services'] += $pv;
+ $marginInfos['pa_total'] += $pa;
+ $marginInfos['pv_total'] += $pv;
+ // if credit note, margin = -1 * (abs(selling_price) - buying_price)
+ if ($pv < 0)
+ $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
+ else
+ $marginInfos['margin_on_services'] += $pv - $pa;
}
}
}
-
- $marginInfos['margin_on_products'] = $marginInfos['pv_products'] - $marginInfos['pa_products'];
if ($marginInfos['pa_products'] > 0)
$marginInfos['margin_rate_products'] = 100 * round($marginInfos['margin_on_products'] / $marginInfos['pa_products'],5);
if ($marginInfos['pv_products'] > 0)
$marginInfos['mark_rate_products'] = 100 * round($marginInfos['margin_on_products'] / $marginInfos['pv_products'],5);
- $marginInfos['margin_on_services'] = $marginInfos['pv_services'] - $marginInfos['pa_services'];
if ($marginInfos['pa_services'] > 0)
$marginInfos['margin_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pa_services'],5);
if ($marginInfos['pv_services'] > 0)
$marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5);
- $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
+ // if credit note, margin = -1 * (abs(selling_price) - buying_price)
+ if ($marginInfos['pv_total'] < 0)
+ $marginInfos['total_margin'] = -1 * (abs($marginInfos['pv_total']) - $marginInfos['pa_total']);
+ else
+ $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total'];
if ($marginInfos['pa_total'] > 0)
$marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5);
if ($marginInfos['pv_total'] > 0)
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 01052d7f642..a6210be79c6 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -191,7 +191,7 @@ class FormCompany
* @param string $htmlname Id of department
* @return void
*/
- function select_departement($selected='',$country_codeid=0, $htmlname='departement_id')
+ function select_departement($selected='',$country_codeid=0, $htmlname='state_id')
{
print $this->select_state($selected,$country_codeid, $htmlname);
}
@@ -208,7 +208,7 @@ class FormCompany
* @param string $htmlname Id of department
* @return string String with HTML select
*/
- function select_state($selected='',$country_codeid=0, $htmlname='departement_id')
+ function select_state($selected='',$country_codeid=0, $htmlname='state_id')
{
global $conf,$langs,$user;
@@ -627,7 +627,7 @@ class FormCompany
{
if (is_object($object) && method_exists($object, 'liste_type_contact'))
{
- $lesTypes = $object->liste_type_contact($source, $order);
+ $lesTypes = $object->liste_type_contact($source, $order, 0, 1);
print '
\n";
}
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 5045283abe3..cf47c22d1fa 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -210,7 +210,7 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='',$minLength=2,
jQuery("#'.$htmlname.'").val(item.value);
// TODO move this to specific request
if (item.states) {
- jQuery("#departement_id").html(item.states);
+ jQuery("#state_id").html(item.states);
}
for (i=0;i 0) // Do not erase state if unknown
{
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index f9c731c097a..5d57abe119c 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -5,7 +5,8 @@
* Copyright (C) 2010-2012 Regis Houssin
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2013 Juanjo Menent
- *
+ * Copyright (C) 2013 Christophe Battarel
+ * *
* 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
* the Free Software Foundation; either version 3 of the License, or
@@ -546,7 +547,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
print "\n".'
'."\n";
- $colspan=6;
+ $colspan=8;
print '
';
print '
'.$langs->trans("Name").'
';
print '
'.$langs->trans("Poste").'
';
@@ -561,10 +562,16 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$colspan++;
print '
';
@@ -1053,7 +1099,7 @@ else
{
print ''.$langs->trans("Validate").'';
}
- if($user->rights->holiday->delete && $cp->statut == 1)
+ if ($user->rights->holiday->delete && $cp->statut == 1) // If draft
{
print ''.$langs->trans("DeleteCP").'';
}
@@ -1064,7 +1110,7 @@ else
print ''.$langs->trans("ActionRefuseCP").'';
}
- if (($user->id == $cp->fk_validator || $user->id == $cp->fk_user) && $cp->statut == 2)
+ if (($user->id == $cp->fk_validator || $user->id == $cp->fk_user) && ($cp->statut == 2 || $cp->statut == 3)) // Status validated or approved
{
if (($cp->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").'';
else print ''.$langs->trans("ActionCancelCP").'';
diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql
index 9f7bf87229c..cd7f1fc285d 100644
--- a/htdocs/install/mysql/data/llx_c_action_trigger.sql
+++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql
@@ -37,6 +37,7 @@ insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang)
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (5,'ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (6,'PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2);
+insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3);
diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
index 0832f299457..f2692015d83 100755
--- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
+++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
@@ -102,7 +102,7 @@ ALTER TABLE llx_expedition DROP FOREIGN KEY fk_expedition_fk_shipping_method;
ALTER TABLE llx_expedition DROP INDEX idx_expedition_fk_expedition_methode;
ALTER TABLE llx_expedition CHANGE COLUMN fk_expedition_methode fk_shipping_method integer;
-ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(256) NOT NULL DEFAULT '' AFTER description;
+ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(255) NOT NULL DEFAULT '' AFTER description;
--ALTER TABLE llx_c_shipment_mode DROP COLUMN CASCADE;
--ALTER TABLE llx_c_shipment_mode ADD COLUMN rowid INTEGER AUTO_INCREMENT PRIMARY KEY;
@@ -249,7 +249,7 @@ CREATE TABLE llx_printer_ipp
datec datetime,
printer_name text NOT NULL,
printer_location text NOT NULL,
- printer_uri varchar(256) NOT NULL,
+ printer_uri varchar(255) NOT NULL,
copy integer NOT NULL DEFAULT '1',
module varchar(16) NOT NULL,
login varchar(32) NOT NULL
diff --git a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql
index 60aacc47626..6fa35fa552c 100755
--- a/htdocs/install/mysql/migration/3.4.0-3.5.0.sql
+++ b/htdocs/install/mysql/migration/3.4.0-3.5.0.sql
@@ -298,3 +298,6 @@ ALTER TABLE llx_facture_fourn ADD fk_mode_reglement integer NULL AFTER fk_cond_r
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_mode_reglement integer NULL;
ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_cond_reglement integer NULL;
+
+insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
+
diff --git a/htdocs/install/mysql/tables/llx_c_shipment_mode.sql b/htdocs/install/mysql/tables/llx_c_shipment_mode.sql
index 37d2d5f85c1..b94936c7461 100644
--- a/htdocs/install/mysql/tables/llx_c_shipment_mode.sql
+++ b/htdocs/install/mysql/tables/llx_c_shipment_mode.sql
@@ -23,7 +23,7 @@ create table llx_c_shipment_mode
code varchar(30) NOT NULL,
libelle varchar(50) NOT NULL,
description text,
- tracking varchar(256) NOT NULL,
+ tracking varchar(255) NOT NULL,
active tinyint DEFAULT 0,
module varchar(32) NULL
)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_printer_ipp.sql b/htdocs/install/mysql/tables/llx_printer_ipp.sql
index 19aa1c4d127..a19e05587d6 100644
--- a/htdocs/install/mysql/tables/llx_printer_ipp.sql
+++ b/htdocs/install/mysql/tables/llx_printer_ipp.sql
@@ -23,7 +23,7 @@ CREATE TABLE llx_printer_ipp
datec datetime,
printer_name text NOT NULL,
printer_location text NOT NULL,
- printer_uri varchar(256) NOT NULL,
+ printer_uri varchar(255) NOT NULL,
copy integer NOT NULL DEFAULT '1',
module varchar(16) NOT NULL,
login varchar(32) NOT NULL
diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang
index 73398da233b..83f06495ffb 100644
--- a/htdocs/langs/en_US/holiday.lang
+++ b/htdocs/langs/en_US/holiday.lang
@@ -89,6 +89,7 @@ FirstDayOfHoliday=First day of holiday
LastDayOfHoliday=Last day of holiday
HolidaysMonthlyUpdate=Monthly update
ManualUpdate=Manual update
+HolidaysCancelation=Holidays cancelation
## Configuration du Module ##
ConfCP=Configuration of holidays module
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 35788d208fa..d3396ea788a 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -658,6 +658,7 @@ Deductible=Deductible
from=from
toward=toward
Access=Access
+HelpCopyToClipboard=Use Ctrl+C to copy to clipboard
# Week day
Monday=Monday
diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang
index 661883a3f12..2ef1b49e152 100644
--- a/htdocs/langs/en_US/orders.lang
+++ b/htdocs/langs/en_US/orders.lang
@@ -56,8 +56,6 @@ DraftOrWaitingShipped=Draft or validated not yet shipped
MenuOrdersToBill=Orders delivered
MenuOrdersToBill2=Orders to bill
SearchOrder=Search order
-Sending=Sending
-Sendings=Sendings
ShipProduct=Ship product
Discount=Discount
CreateOrder=Create Order
diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang
index 2b7c7f98140..609066453ab 100644
--- a/htdocs/langs/en_US/sendings.lang
+++ b/htdocs/langs/en_US/sendings.lang
@@ -3,6 +3,7 @@ CHARSET=UTF-8
RefSending=Ref. shipment
Sending=Shipment
Sendings=Shipments
+Shipment=Shipment
Shipments=Shipments
Receivings=Receivings
SendingsArea=Shipments area
diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang
index b70c1797892..8efdd8e3624 100644
--- a/htdocs/langs/fr_FR/agenda.lang
+++ b/htdocs/langs/fr_FR/agenda.lang
@@ -37,7 +37,7 @@ AutoActions= Alimentation automatique
AgendaAutoActionDesc= Définissez dans cet onglet les événements pour lesquels Dolibarr créera automatiquement une action dans l'agenda. Si aucune case n'est cochée (par défaut), seules les actions manuelles seront incluses dans l'agenda.
AgendaSetupOtherDesc= Cette page permet de configurer quelques options permettant d'exporter une vue de votre agenda Dolibarr vers un calendrier externe (Thunderbird, Google calendar, …)
AgendaExtSitesDesc=Cette page permet d'ajouter des sources de calendriers externes pour les visualiser au sein de l'agenda Dolibarr.
-ActionsEvents= Événements pour lesquels Dolibarr doit créer une action dans l'agenda en automatique.
+ActionsEvents= Événements pour lesquels Dolibarr doit insérer un évènement dans l'agenda en automatique.
PropalValidatedInDolibarr= Proposition %s validée
InvoiceValidatedInDolibarr= Facture %s validée
InvoiceBackToDraftInDolibarr=Facture %s repassée en brouillon
diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang
index f690a9c764c..b6569ee5f4d 100644
--- a/htdocs/langs/fr_FR/holiday.lang
+++ b/htdocs/langs/fr_FR/holiday.lang
@@ -89,6 +89,7 @@ FirstDayOfHoliday=Premier jour de congés
LastDayOfHoliday=Dernier jour de congés
HolidaysMonthlyUpdate=Mise à jour mensuelle
ManualUpdate=Mise à jour manuelle
+HolidaysCancelation=Annulation de congès
## Configuration du Module ##
ConfCP=Configuration du module Congés
diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang
index c92b0de4148..78f3a35875b 100644
--- a/htdocs/langs/fr_FR/mails.lang
+++ b/htdocs/langs/fr_FR/mails.lang
@@ -105,7 +105,7 @@ NbOfCompaniesContacts=Contacts/adresses uniques
MailNoChangePossible=Destinataires d'un emailing validé non modifiables
SearchAMailing=Rechercher un emailing
SendMailing=Envoi emailing
-SendMail=Envoi email
+SendMail=Envoyer email
SentBy=Envoyé par
MailingNeedCommand=Pour des raisons de sécurité, il est recommandé de faire les envois d'un mailing de masse depuis la ligne de commande. Si en avez, demandez à votre administrateur de serveurs de lancer la commande suivante pour envoyer le mailing à tous les destinataires :
MailingNeedCommand2=Vous pouvez toutefois quand même les envoyer par l'interface écran en ajoutant le paramètre MAILING_LIMIT_SENDBYWEB avec la valeur du nombre max de mails envoyés par session d'envoi. Pour cela, aller dans Accueil - Configuration - Divers.
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index ee591bb4535..b34b784165a 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -658,6 +658,7 @@ Deductible=Déductible
from=de
toward=vers
Access=Accès
+HelpCopyToClipboard=Ctrl+C pour copier dans le presse-papier
# Week day
Monday=Lundi
diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang
index 79796a0a907..644075e9a6b 100644
--- a/htdocs/langs/fr_FR/orders.lang
+++ b/htdocs/langs/fr_FR/orders.lang
@@ -56,8 +56,6 @@ DraftOrWaitingShipped=Brouillon ou validée pas encore expédiée
MenuOrdersToBill=Commandes délivrées
MenuOrdersToBill2=Commandes à facturer
SearchOrder=Rechercher une commande
-Sending=Expédition
-Sendings=Expéditions
ShipProduct=Expédier produit
Discount=Remise
CreateOrder=Créer Commande
diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang
index a4ddaafef01..3d8088624c6 100644
--- a/htdocs/langs/fr_FR/sendings.lang
+++ b/htdocs/langs/fr_FR/sendings.lang
@@ -3,6 +3,7 @@ CHARSET=UTF-8
RefSending=Réf. expédition
Sending=Expédition
Sendings=Expéditions
+Shipment=Expédition
Shipments=Expéditions
Receivings=Réceptions
SendingsArea=Espace expéditions
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index 44c0bc91166..9fdb13ffe40 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -479,7 +479,7 @@ else
$soc->fetch($delivery->socid);
$head=delivery_prepare_head($delivery);
- dol_fiche_head($head, 'delivery', $langs->trans("Sending"), 0, 'sending');
+ dol_fiche_head($head, 'delivery', $langs->trans("Shipment"), 0, 'sending');
/*
* Confirmation de la suppression
@@ -489,7 +489,7 @@ else
{
$expedition_id = $_GET["expid"];
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$delivery->id.'&expid='.$expedition_id,$langs->trans("DeleteDeliveryReceipt"),$langs->trans("DeleteDeliveryReceiptConfirm",$delivery->ref),'confirm_delete','','',1);
-
+
}
/*
@@ -499,7 +499,7 @@ else
if ($action == 'valid')
{
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$delivery->id,$langs->trans("ValidateDeliveryReceipt"),$langs->trans("ValidateDeliveryReceiptConfirm",$delivery->ref),'confirm_valid','','',1);
-
+
}
diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php
index c5237d219c5..bfa5d530e29 100644
--- a/htdocs/margin/lib/margins.lib.php
+++ b/htdocs/margin/lib/margins.lib.php
@@ -117,12 +117,18 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta
// calcul pu_ht remisés
$tabprice=calcul_price_total(1, $pvht, $remise_percent, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 'HT', 0, 0); // FIXME Parameter type is missing, i put 0 to avoid blocking error
$pu_ht_remise = $tabprice[0];
+ // calcul marge
+ if ($pu_ht_remise < 0)
+ $marge = -1 * (abs($pu_ht_remise) - $paht_ret);
+ else
+ $marge = $pu_ht_remise - $paht_ret;
+
// calcul taux marge
if ($paht_ret != 0)
- $marge_tx_ret = round((100 * ($pu_ht_remise - $paht_ret)) / $paht_ret, 3);
+ $marge_tx_ret = round((100 * $marge) / $paht_ret, 3);
// calcul taux marque
if ($pu_ht_remise != 0)
- $marque_tx_ret = round((100 * ($pu_ht_remise - $paht_ret)) / $pu_ht_remise, 3);
+ $marque_tx_ret = round((100 * $marge) / $pu_ht_remise, 3);
return array($paht_ret, $marge_tx_ret, $marque_tx_ret);
}
diff --git a/htdocs/product/admin/product_extrafields.php b/htdocs/product/admin/product_extrafields.php
index 98b85746051..3f4ff84655e 100644
--- a/htdocs/product/admin/product_extrafields.php
+++ b/htdocs/product/admin/product_extrafields.php
@@ -52,7 +52,7 @@ if (!$user->admin) accessforbidden();
* Actions
*/
-require DOL_DOCUMENT_ROOT.'/core/admin_extrafields.inc.php';
+require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php
index c98c6c23e96..1d0a9c08e04 100644
--- a/htdocs/product/stock/fiche.php
+++ b/htdocs/product/stock/fiche.php
@@ -191,9 +191,9 @@ if ($action == 'create')
// Zip / Town
print '