Преглед изворни кода

Possibilité de règlement multiple sur solde ou montant quelconque

Mathieu Moulin пре 2 година
родитељ
комит
bf5ee56bb6

+ 13 - 0
class/actions_mbietransactions.class.php

@@ -126,6 +126,19 @@ class ActionsMBIETransactions extends MMI_Actions_1_0
 		// var_dump($object->array_options['options_acompte']);
 		// var_dump($object->total_ttc);
 
+		// Multiple Reste
+		if (!empty($parameters['amount']) && (!empty($object->array_options['options_pay_solde_mult_ok'])) && ($reste>=300 || ($object->total_ttc>300 && $reste===NULL))) {
+			$multiple = 3;
+			$link_multiple = mmi_etransactions::paymentlink($objecttype, $object->id, $parameters['amount'], $multiple, true);
+			print '<div class="button buttonpayment" id="div_dopayment_mbietransactions_multiple">
+			<input class="" type="submit" id="dopayment_mbietransactions_multiple" name="dopayment_mbietransactions" value="'.$langs->trans("MBIETransactionsDoPaymentMultiple", $multiple).'">';
+			print '<br />';
+			print '<span class="buttonpaymentsmall">
+			<img src="/custom/mbietransactions/img/cb-visa-mastercard.png" alt="CB Visa Mastercard" class="img_cb" />
+			<img src="/custom/mbietransactions/img/amex.png" alt="Amex" class="img_amex" />
+			</span>';
+			print '</div>';
+		}
 		// Multiple
 		if (empty($parameters['amount']) && ($reste>=300 || ($object->total_ttc>300 && $reste===NULL))) {
 			$multiple = 3;

+ 13 - 22
core/modules/modMBIETransactions.class.php

@@ -39,8 +39,8 @@ class modMBIETransactions extends DolibarrModules
 		$this->description = "MBIETransactionsDescription";
 		$this->descriptionlong = "MBIETransactions description (Long)";
 		$this->editor_name = 'Mathieu Moulin iProspective';
-		$this->editor_url = 'https://www.iprospective.fr';
-		$this->version = '1.0.1';
+		$this->editor_url = 'https://iprospective.fr';
+		$this->version = '1.0.2';
 
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
 		$this->picto = 'logo@mbietransactions';
@@ -84,25 +84,13 @@ class modMBIETransactions extends DolibarrModules
 		// Permissions provided by this module
 		$this->rights = array();
 		$r = 0;
-		// Add here entries to declare new permissions
-		/* BEGIN MODULEBUILDER PERMISSIONS */
-		/*
-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
-		$this->rights[$r][1] = 'Read objects of MBIETransactions'; // Permission label
-		$this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
-		$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
-		$r++;
 		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
-		$this->rights[$r][1] = 'Create/Update objects of MBIETransactions'; // Permission label
-		$this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
+		$this->rights[$r][1] = 'MBIETransactionsPaymentSoldeMultOK'; // Permission label
+		$this->rights[$r][4] = 'pay_solde_mult'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
 		$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
 		$r++;
-		$this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
-		$this->rights[$r][1] = 'Delete objects of MBIETransactions'; // Permission label
-		$this->rights[$r][4] = 'myobject'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
-		$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mbietransactions->level1->level2)
-		$r++;
-		*/
+		// Add here entries to declare new permissions
+		/* BEGIN MODULEBUILDER PERMISSIONS */
 		/* END MODULEBUILDER PERMISSIONS */
 
 		$this->menu = array();
@@ -128,14 +116,17 @@ class modMBIETransactions extends DolibarrModules
 		// Create extrafields during init
 		include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
 		$extrafields = new ExtraFields($this->db);
+
+		// Propal
 		$extrafields->addExtraField('acompte', $langs->trans("MBIETransactionsAcompte"), 'double', 100, "4,2", 'propal', 0, 0, '', 0, true, '', -1, 0);
 		$extrafields->addExtraField('acompte_val', $langs->trans("MBIETransactionsAcompteVal"), 'price', 100, "8,2", 'propal', 0, 0, '', 0, true, '', -1, 0);
+
+		// Commande
 		$extrafields->addExtraField('acompte', $langs->trans("MBIETransactionsAcompte"), 'double', 100, "4,2", 'commande', 0, 0, '', 0, true, '', -1, 0);
 		$extrafields->addExtraField('acompte_val', $langs->trans("MBIETransactionsAcompteVal"), 'price', 100, "8,2", 'commande', 0, 0, '', 0, true, '', -1, 0);
-		//$extrafields->addExtraField('mbi_payment_link', $langs->trans("MBIETransactionsPaymentLink"), 'text', 100, '2000', 'facture', 0, 0, '', '', 0, '', '1', '', '', $conf->entity, '', '1', 0, 0);
-		//$extrafields->addExtraField('mbi_image_link', $langs->trans("MBIETransactionsTrustImage"), 'text', 100, '2000', 'facture', 0, 0, '', '', 0, '', '1', '', '', $conf->entity, '', '1', 0, 0);
-		//$extrafields->addExtraField('mbi_payment_deposit', $langs->trans("MBIETransactionsAdvanceAmountTTC"), 'varchar', 100, '2000', 'facture', 0, 0, '', '', 1, '', '1', '', '', $conf->entity, '', '1', 0, 0);
-		//$extrafields->addExtraField('mbi_payment_multiple', $langs->trans("MBIETransactionsPaymentMultiple"), 'select', 100, '', 'facture', 0, 0, '', 'a:1:{s:7:"options";a:2:{i:2;s:1:"2";i:3;s:1:"3";}}', 1, '', '1', '', '', $conf->entity, '', '1', 0, 0);
+
+		// Facture
+		$extrafields->addExtraField('pay_solde_mult_ok', $langs->trans("MBIETransactionsPaymentSoldeMultOK"), 'boolean', 10, '', 'facture', 0, 0, '', -1, true, '$conf->mbietransactions->enabled && $user->rights->mbietransactions->pay_solde_mult->write', 0, 0);
 
 		// Permissions
 		$this->remove($options);

+ 1 - 0
langs/fr_FR/mbietransactions.lang

@@ -105,6 +105,7 @@ MBIETransactionsMailTitlePaymentLink = Lien pour le règlement de la facture __R
 MBIETransactionsPaymentPageContinue = Continuer
 MBIETransactionsPaymentPageDeadline = Échéance
 MBIETransactionsPaymentMultiple = Paiement en x fois
+MBIETransactionsPaymentSoldeMultOK = Autoriser le x fois sur un reste à payer (éventuellement saisi manuellement)
 
 #
 # Pages de paiement Standard

+ 10 - 9
payment.php

@@ -62,7 +62,7 @@ $extrafields2 = $object->array_options;
 
 // Multiple : total ou solde
 if ($obj->multiple) {
-	$resteapayer = price2num($resteapayer);
+	$resteapayer = price2num($obj->amount ?$obj->amount :$resteapayer);
 	$extrafields2['options_mbi_payment_multiple'] = $obj->multiple;
 }
 // Acompte : d'un coup
@@ -102,6 +102,7 @@ if (!$confError) {
 	
 	$pbx_total = $resteapayer * 100;
 	//var_dump($object); die();
+	//var_dump($pbx_total ); die();
 	$usercode = '';
 
 	$contacts = $object->liste_contact(-1, 'internal');
@@ -135,12 +136,12 @@ if (!$confError) {
 	$pbx_total = str_replace(",", "", $pbx_total);
 	$pbx_total = str_replace(".", "", $pbx_total);
 
-	if ($extrafields2['options_mbi_payment_multiple'] == "2" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	if ($extrafields2['options_mbi_payment_multiple'] == "2") {
 		$total = $resteapayer * 100;
 		$pbx_total = floor($total / 2);
 		$pbx_2mont1 = $total - $pbx_total;
 		$pbx_date1 = date('d/m/Y',strtotime('+1 month'));
-	} else if ($extrafields2['options_mbi_payment_multiple'] == "3" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	} else if ($extrafields2['options_mbi_payment_multiple'] == "3") {
 		$total = $resteapayer * 100;
 		$pbx_total = floor($total / 3);
 		$pbx_2mont1 = $pbx_total;
@@ -198,10 +199,10 @@ if (!$confError) {
 		"&PBX_HASH=SHA512" .
 		"&PBX_TIME=" . $dateTime;
 
-	if ($extrafields2['options_mbi_payment_multiple'] == "2" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	if ($extrafields2['options_mbi_payment_multiple'] == "2") {
 		$msg .= "&PBX_2MONT1=" . $pbx_2mont1;
 		$msg .= "&PBX_DATE1=" . $pbx_date1;
-	} else if ($extrafields2['options_mbi_payment_multiple'] == "3" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	} else if ($extrafields2['options_mbi_payment_multiple'] == "3") {
 		$msg .= "&PBX_2MONT1=" . $pbx_2mont1;
 		$msg .= "&PBX_DATE1=" . $pbx_date1;
 		$msg .= "&PBX_2MONT2=" . $pbx_2mont2;
@@ -226,10 +227,10 @@ if (!$confError) {
 	."<input type='hidden' name='PBX_REFUSE' value='" . $pbx_refuse . "'>"
 	."<input type='hidden' name='PBX_HASH' value='SHA512'>"
 	."<input type='hidden' name='PBX_TIME' value='" . $dateTime . "'>";
-	if ($extrafields2['options_mbi_payment_multiple'] == "2" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	if ($extrafields2['options_mbi_payment_multiple'] == "2") {
 		$form .= "<input type='hidden' name='PBX_2MONT1' value='" . $pbx_2mont1 . "'>";
 		$form .= "<input type='hidden' name='PBX_DATE1' value='" . $pbx_date1 . "'>";
-	} else if ($extrafields2['options_mbi_payment_multiple'] == "3" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	} else if ($extrafields2['options_mbi_payment_multiple'] == "3") {
 		$form .= "<input type='hidden' name='PBX_2MONT1' value='" . $pbx_2mont1 . "'>";
 		$form .= "<input type='hidden' name='PBX_DATE1' value='" . $pbx_date1 . "'>";
 		$form .= "<input type='hidden' name='PBX_2MONT2' value='" . $pbx_2mont2 . "'>";
@@ -279,9 +280,9 @@ if (!$confError) {
 		echo "<tr><td class='payment-row-left'><strong>" . $langs->trans("MBIETransactionsPaymentRecapPaymentAmount") . "</strong></td><td class='payment-row-right'><strong>" . price($pbx_total / 100) . " € TTC</strong></td></tr>";
 	}
 	// Paiement en plusieurs fois
-	if ($extrafields2['options_mbi_payment_multiple'] == "2" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	if ($extrafields2['options_mbi_payment_multiple'] == "2") {
 		echo "<tr><td>" . $langs->trans("MBIETransactionsPaymentPageDeadline") . " : " . price($pbx_2mont1 / 100) . " € TTC - " . $pbx_date1 . "</td></tr>";
-	} else if ($extrafields2['options_mbi_payment_multiple'] == "3" && empty($extrafields2['options_mbi_payment_deposit'])) {
+	} else if ($extrafields2['options_mbi_payment_multiple'] == "3") {
 		echo "<tr><td>" . $langs->trans("MBIETransactionsPaymentPageDeadline") . " : " . price($pbx_2mont1 / 100) . " € TTC - " . $pbx_date1 . "</td></tr>";
 		echo "<tr><td>" . $langs->trans("MBIETransactionsPaymentPageDeadline") . " : " . price($pbx_2mont2 / 100) . " € TTC - " . $pbx_date2 . "</td></tr>";
 	}