Browse Source

Merge branch 'loan' of https://github.com/frederic34/dolibarr into
frederic34-loan

Conflicts:
htdocs/compta/bank/ligne.php

Laurent Destailleur 10 years ago
parent
commit
b83e9ea32f

+ 30 - 8
htdocs/admin/supplier_order.php

@@ -165,13 +165,24 @@ else if ($action == 'addcat')
     $fourn->CreateCategory($user,$_POST["cat"]);
 }
 
-else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
+else if ($action == 'set_SUPPLIER_ORDER_OTHER')
 {
     $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT');	// No alpha here, we want exact string
-
-    $res = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
-
-    if (! $res > 0) $error++;
+	$doubleapproval = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL');
+	$doubleapprovalgroup = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP') > 0 ? GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP') : '';
+	
+    $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
+    $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL",$doubleapproval,'chaine',0,'',$conf->entity);
+    if (isset($_POST["SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP"]))
+    {
+    	$res3 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP",$doubleapprovalgroup,'chaine',0,'',$conf->entity);
+    }
+    else
+    {
+    	$res3=1;
+    }
+    
+    if (! $res1 > 0 || ! $res2 > 0 || ! $res3 > 0) $error++;
 
 	if (! $error)
 	{
@@ -188,12 +199,12 @@ else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT')
  * View
  */
 
+$form=new Form($db);
+
 $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
 
 llxHeader("","");
 
-$form=new Form($db);
-
 $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
 print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
 
@@ -447,7 +458,7 @@ print '</table><br>';
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-print '<input type="hidden" name="action" value="set_SUPPLIER_ORDER_FREE_TEXT">';
+print '<input type="hidden" name="action" value="set_SUPPLIER_ORDER_OTHER">';
 
 print_titre($langs->trans("OtherOptions"));
 print '<table class="noborder" width="100%">';
@@ -457,6 +468,17 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
 print '<td width="80">&nbsp;</td>';
 print "</tr>\n";
 
+if ($conf->global->MAIN_FEATURES_LEVEL > 0)
+{
+	print '<tr '.$bc[$var].'><td>';
+	print $langs->trans("UseDoubleApproval").'</td><td>';
+	print $form->selectyesno('SUPPLIER_ORDER_DOUBLE_APPROVAL', $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL);
+	print '<br>'.$form->select_dolgroups($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP,'SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP', 1);
+	print '</td><td align="right">';
+	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+	print "</td></tr>\n";
+}
+
 print '<tr '.$bc[$var].'><td colspan="2">';
 print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>';
 print '<textarea name="SUPPLIER_ORDER_FREE_TEXT" class="flat" cols="120">'.$conf->global->SUPPLIER_ORDER_FREE_TEXT.'</textarea>';

+ 1 - 0
htdocs/categories/admin/categorie_extrafields.php

@@ -49,6 +49,7 @@ if (!$user->admin) accessforbidden();
 /*
  * Actions
  */
+
 require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
 
 

+ 13 - 0
htdocs/compta/bank/ligne.php

@@ -35,6 +35,7 @@ $langs->load("compta");
 $langs->load("bills");
 if (! empty($conf->adherent->enabled)) $langs->load("members");
 if (! empty($conf->don->enabled)) $langs->load("donations");
+if (! empty($conf->loan->enabled)) $langs->load("loan");
 
 
 $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
@@ -347,6 +348,18 @@ if ($result)
                     print $langs->trans("SalaryPayment");
                     print '</a>';
                 }
+                else if ($links[$key]['type']=='payment_loan') {
+                    print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
+                    print img_object($langs->trans('ShowLoanPayment'),'payment').' ';
+                    print $langs->trans("PaymentLoan");
+                    print '</a>';
+                }
+                else if ($links[$key]['type']=='loan') {
+                    print '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$links[$key]['url_id'].'">';
+                    print img_object($langs->trans('ShowLoan'),'bill').' ';
+                    print $langs->trans("Loan");
+                    print '</a>';
+                }
                 else if ($links[$key]['type']=='member') {
                     print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
                     print img_object($langs->trans('ShowMember'),'user').' ';

+ 2 - 2
htdocs/core/class/extrafields.class.php

@@ -74,11 +74,11 @@ class ExtraFields
 	'mail'=>'ExtrafieldMail',
 	'select' => 'ExtrafieldSelect',
 	'sellist' => 'ExtrafieldSelectList',
-	'separate' => 'ExtrafieldSeparator',
-	'checkbox' => 'ExtrafieldCheckBox',
 	'radio' => 'ExtrafieldRadio',
+	'checkbox' => 'ExtrafieldCheckBox',
 	'chkbxlst' => 'ExtrafieldCheckBoxFromList',
 	'link' => 'ExtrafieldLink',
+	'separate' => 'ExtrafieldSeparator',
 	);
 
 	/**

+ 16 - 9
htdocs/core/tpl/admin_extrafields_add.tpl.php

@@ -15,6 +15,14 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
+
+/**
+ * The following vars must be defined
+ * $type2label
+ * $form
+ * $conf, $lang, 
+ */
+
 ?>
 
 <!-- BEGIN PHP TEMPLATE admin_extrafields_add.tpl.php -->
@@ -47,13 +55,13 @@
     		else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); }
     		else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
     		else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
-    		else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
-    		else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();}
-    		else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();}
-    		else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
-    		else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();}
-    		else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
-    		else if (type == 'chkbxlst') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").hide(); jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();}
+    		else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
+    		else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();;jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();}
+    		else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
+    		else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
+    		else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
+    		else if (type == 'chkbxlst') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();}
+    		else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled');  required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();}
     		else size.val('').attr('disabled','disabled');
     	}
     	init_typeoffields('<?php echo GETPOST('type'); ?>');
@@ -66,7 +74,6 @@
 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
 <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
 <input type="hidden" name="action" value="add">
-<input type="hidden" name="rowid" value="<?php echo $rowid ?>">
 
 <table summary="listofattributes" class="border centpercent">
 <!-- Label -->
@@ -90,7 +97,7 @@
 <td>
 <table class="nobordernopadding">
 <tr><td>
-	<textarea name="param" id="param" cols="80" rwos="<?php echo ROWS_4 ?>"><?php echo GETPOST('param'); ?></textarea>
+	<textarea name="param" id="param" cols="80" rows="<?php echo ROWS_4 ?>"><?php echo GETPOST('param'); ?></textarea>
 </td><td id="helpselect"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?></td>
 <td><span id="helpsellist"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?></span>
 <span id="helpchkbxlst"><?php print $form->textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?></span></td></tr>

+ 1 - 0
htdocs/langs/en_US/admin.lang

@@ -389,6 +389,7 @@ ExtrafieldSeparator=Separator
 ExtrafieldCheckBox=Checkbox
 ExtrafieldRadio=Radio button
 ExtrafieldCheckBoxFromList= Checkbox from table
+ExtrafieldLink=Link to an object
 ExtrafieldParamHelpselect=Parameters list have to be like key,value<br><br> for example : <br>1,value1<br>2,value2<br>3,value3<br>...<br><br>In order to have the list depending on another :<br>1,value1|parent_list_code:parent_key<br>2,value2|parent_list_code:parent_key
 ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value<br><br> for example : <br>1,value1<br>2,value2<br>3,value3<br>...
 ExtrafieldParamHelpradio=Parameters list have to be like key,value<br><br> for example : <br>1,value1<br>2,value2<br>3,value3<br>...

+ 1 - 0
htdocs/langs/en_US/loan.lang

@@ -4,6 +4,7 @@ Loans=Loans
 NewLoan=New Loan
 ShowLoan=Show Loan
 PaymentLoan=Loan payment
+ShowLoanPayment=Show Loan Payment
 Capital=Capital
 Insurance=Insurance
 Interest=Interest

+ 2 - 1
htdocs/langs/en_US/suppliers.lang

@@ -42,4 +42,5 @@ SentToSuppliers=Sent to suppliers
 ListOfSupplierOrders=List of supplier orders
 MenuOrdersSupplierToBill=Supplier orders to invoice
 NbDaysToDelivery=Delivery delay in days
-DescNbDaysToDelivery=The biggest delay is display among order product list
+DescNbDaysToDelivery=The biggest delay is display among order product list
+UseDoubleApproval=Use double approval (the second approval will be any user of a defined user group)

+ 2 - 2
htdocs/loan/class/paymentloan.class.php

@@ -391,7 +391,7 @@ class PaymentLoan extends CommonObject
      *      @param  string	$emetteur_banque    Name of bank
      *      @return int                 		<0 if KO, >0 if OK
      */
-    function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque)
+    function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
     {
         global $conf;
 
@@ -448,7 +448,7 @@ class PaymentLoan extends CommonObject
                 //$linkaddedforthirdparty=array();
                 if ($mode == 'payment_loan')
                 {
-                    $result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/loan/card.php?id=', $this->type_libelle.(($this->label && $this->label!=$this->type_libelle)?' ('.$this->label.')':''),'loan');
+                    $result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan');
                     if ($result <= 0) dol_print_error($this->db);
                 }
             }

+ 4 - 4
htdocs/loan/payment/payment.php

@@ -41,6 +41,9 @@ if ($user->societe_id > 0)
 	$socid = $user->societe_id;
 }
 
+$loan = new Loan($db);
+$loan->fetch($chid);
+
 /*
  * Actions
  */
@@ -92,6 +95,7 @@ if ($action == 'add_payment')
     		$payment = new PaymentLoan($db);
     		$payment->chid				= $chid;
     		$payment->datepaid			= $datepaid;
+            $payment->label             = $loan->label;
 			$payment->amount_capital	= GETPOST('amount_capital');
 			$payment->amount_insurance	= GETPOST('amount_insurance');
 			$payment->amount_interest	= GETPOST('amount_interest');
@@ -150,10 +154,6 @@ $form=new Form($db);
 // Form to create loan's payment
 if ($_GET["action"] == 'create')
 {
-
-	$loan = new Loan($db);
-	$loan->fetch($chid);
-
 	$total = $loan->capital;
 
 	print_fiche_titre($langs->trans("DoPayment"));