Prechádzať zdrojové kódy

Merge branch '15.0' of git@github.com:Dolibarr/dolibarr.git into 16.0

Conflicts:
	htdocs/core/class/commonobject.class.php
	htdocs/core/lib/signature.lib.php
Laurent Destailleur 1 rok pred
rodič
commit
4298150413

+ 2 - 0
ChangeLog

@@ -1331,6 +1331,8 @@ Following changes may create regressions for some external modules, but were nec
 * v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8.
 * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in 
   method executeCLI() available into core/class/utils.class.php  
+* the trigger "*_DELETE_CONTACT" inside "delete_contact()" function from commonobject.class.php is call before delete the object element
+  and a $object->context['contact_id'] is now available for this trigger
 
 
 ***** ChangeLog for 13.0.5 compared to 13.0.4 *****

+ 9 - 6
htdocs/comm/propal/card.php

@@ -1986,9 +1986,12 @@ if ($action == 'create') {
 	/*
 	 * Show object in view mode
 	 */
-
-	$soc = new Societe($db);
-	$soc->fetch($object->socid);
+	$object->fetch_thirdparty();
+	if ($object->thirdparty) {
+		$soc = $object->thirdparty;
+	} else {
+		$soc = new Societe($db);
+	}
 
 	$head = propal_prepare_head($object);
 	print dol_get_fiche_head($head, 'comm', $langs->trans('Proposal'), -1, 'propal');
@@ -2225,9 +2228,9 @@ if ($action == 'create') {
 	$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><span class="hideonsmartphone">'.$langs->trans('ThirdParty').' : </span>'.$object->thirdparty->getNomUrl(1, 'customer');
-	if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
-		$morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)';
+	$morehtmlref .= '<br><span class="hideonsmartphone">'.$langs->trans('ThirdParty').' : </span>'.$soc->getNomUrl(1, 'customer');
+	if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $soc->id > 0) {
+		$morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?socid='.$soc->id.'&search_societe='.urlencode($soc->name).'">'.$langs->trans("OtherProposals").'</a>)';
 	}
 	// Project
 	if (!empty($conf->project->enabled)) {

+ 2 - 0
htdocs/compta/facture/card.php

@@ -1927,6 +1927,8 @@ if (empty($reshook)) {
 				$object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
 				$object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU', 2);
 				$object->remise_percent = price2num(GETPOST('remise_percent'), '', 2);
+				$object->fk_account = GETPOST('fk_account', 'int');
+
 
 				// Proprietes particulieres a facture de remplacement
 

+ 1 - 0
htdocs/compta/facture/class/facture.class.php

@@ -1164,6 +1164,7 @@ class Facture extends CommonInvoice
 
 		$facture->origin            = $this->origin;
 		$facture->origin_id         = $this->origin_id;
+		$facture->fk_account         = $this->fk_account;
 
 		$facture->lines = $this->lines; // Array of lines of invoice
 		$facture->situation_counter = $this->situation_counter;

+ 22 - 10
htdocs/core/class/commonobject.class.php

@@ -1271,22 +1271,34 @@ abstract class CommonObject
 		// phpcs:enable
 		global $user;
 
+		$error = 0;
 
 		$this->db->begin();
 
-		$sql = "DELETE FROM ".$this->db->prefix()."element_contact";
-		$sql .= " WHERE rowid = ".((int) $rowid);
+		if (!$error && empty($notrigger)) {
+			// Call trigger
+			$this->context['contact_id'] = ((int) $rowid);
+			$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
+			if ($result < 0) {
+				$error++;
+			}
+			// End call triggers
+		}
 
-		dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
-		if ($this->db->query($sql)) {
-			if (!$notrigger) {
-				$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
-				if ($result < 0) {
-					$this->db->rollback();
-					return -1;
-				}
+		if (!$error) {
+			dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
+
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
+			$sql .= " WHERE rowid = ".((int) $rowid);
+
+			$result = $this->db->query($sql);
+			if (!$result) {
+				$error++;
+				$this->errors[] = $this->db->lasterror();
 			}
+		}
 
+		if (!$error) {
 			$this->db->commit();
 			return 1;
 		} else {

+ 26 - 13
htdocs/core/lib/signature.lib.php

@@ -20,11 +20,12 @@
 /**
  * Return string with full online Url to accept and sign a quote
  *
- * @param   string	$type		Type of URL ('proposal', ...)
- * @param	string	$ref		Ref of object
+ * @param   string			$type		Type of URL ('proposal', ...)
+ * @param	string			$ref		Ref of object
+ * @param   CommonObject  	$obj  		object (needed to make multicompany good links)
  * @return	string				Url string
  */
-function showOnlineSignatureUrl($type, $ref)
+function showOnlineSignatureUrl($type, $ref, CommonObject $obj = null)
 {
 	global $conf, $langs;
 
@@ -34,7 +35,7 @@ function showOnlineSignatureUrl($type, $ref)
 	$servicename = 'Online';
 
 	$out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'</span><br>';
-	$url = getOnlineSignatureUrl(0, $type, $ref);
+	$url = getOnlineSignatureUrl(0, $type, $ref, $obj);
 	$out .= '<div class="urllink">';
 	if ($url == $langs->trans("FeatureOnlineSignDisabled")) {
 		$out .= $url;
@@ -51,15 +52,27 @@ function showOnlineSignatureUrl($type, $ref)
 /**
  * Return string with full Url
  *
- * @param   int		$mode				0=True url, 1=Url formated with colors
- * @param   string	$type				Type of URL ('proposal', ...)
- * @param	string	$ref				Ref of object
- * @param   string  $localorexternal  	0=Url for browser, 1=Url for external access
+ * @param   int				$mode				0=True url, 1=Url formated with colors
+ * @param   string			$type				Type of URL ('proposal', ...)
+ * @param	string			$ref				Ref of object
+ * @param   string  		$localorexternal  	0=Url for browser, 1=Url for external access
+ * @param   CommonObject  	$obj  				object (needed to make multicompany good links)
  * @return	string						Url string
  */
-function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
+function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, CommonObject $obj = null)
 {
-	global $conf, $object, $dolibarr_main_url_root;
+	global $conf, $dolibarr_main_url_root;
+
+	if (empty($obj)) {
+		// For compatibility with 15.0 -> 19.0
+		global $object;
+        if (empty($object)) {
+            $obj = new CommonObject();
+        } else {
+			dol_syslog(__METHOD__." using global object is deprecated, please give obj as argument", LOG_WARNING);
+			$obj = $object;
+		}
+	}
 
 	$ref = str_replace(' ', '', $ref);
 	$out = '';
@@ -77,7 +90,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
 	$securekeyseed = '';
 
 	if ($type == 'proposal') {
-		$securekeyseed = isset($conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN : '';
+		$securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
 
 		$out = $urltouse.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<span style="color: #666666">' : '');
 		if ($mode == 1) {
@@ -90,7 +103,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
 		if ($mode == 1) {
 			$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
 		} else {
-			$out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $object->entity), '0');
+			$out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $obj->entity), '0');
 		}
 		/*
 		if ($mode == 1) {
@@ -120,7 +133,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
 
 	// For multicompany
 	if (!empty($out) && !empty($conf->multicompany->enabled)) {
-		$out .= "&entity=".$object->entity; // Check the entity because we may have the same reference in several entities
+		$out .= "&entity=".((int) $obj->entity); // Check the entity of object because we may have the same reference in several entities
 	}
 
 	return $out;