浏览代码

Uniformize code

Laurent Destailleur 8 年之前
父节点
当前提交
e79a84a89b
共有 4 个文件被更改,包括 372 次插入367 次删除
  1. 4 77
      htdocs/commande/card.php
  2. 280 236
      htdocs/compta/bank/card.php
  3. 87 53
      htdocs/compta/bank/class/account.class.php
  4. 1 1
      htdocs/core/class/commoninvoice.class.php

+ 4 - 77
htdocs/commande/card.php

@@ -60,13 +60,13 @@ $langs->load('deliveries');
 $langs->load('sendings');
 $langs->load('products');
 if (!empty($conf->incoterm->enabled)) $langs->load('incoterm');
-if (! empty($conf->margin->enabled))
-	$langs->load('margins');
+if (! empty($conf->margin->enabled)) $langs->load('margins');
 
 $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('orderid', 'int'));
 $ref = GETPOST('ref', 'alpha');
 $socid = GETPOST('socid', 'int');
 $action = GETPOST('action', 'alpha');
+$cancel = GETPOST('cancel', 'alpha');
 $confirm = GETPOST('confirm', 'alpha');
 $lineid = GETPOST('lineid', 'int');
 $origin = GETPOST('origin', 'alpha');
@@ -1765,16 +1765,12 @@ if ($action == 'create' && $user->rights->commande->creer)
 
 		$formconfirm = '';
 
-		/*
-		 * Confirmation de la suppression de la commande
-		*/
+		// Confirmation to delete
 		if ($action == 'delete') {
 			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
 		}
 
-		/*
-		 * Confirmation de la validation
-		*/
+		// Confirmation of validation
 		if ($action == 'validate')
 		{
 			// on verifie si l'objet est en numerotation provisoire
@@ -1981,52 +1977,6 @@ if ($action == 'create' && $user->rights->commande->creer)
 
 	    print '<table class="border" width="100%">';
 
-		// Ref
-		/*
-		print '<tr><td class="titlefield">' . $langs->trans('Ref') . '</td>';
-		print '<td colspan="3">';
-		print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
-		print '</td>';
-		print '</tr>';
-
-		// Ref commande client
-		print '<tr><td>';
-		print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
-		print $langs->trans('RefCustomer') . '</td><td align="left">';
-		print '</td>';
-		if ($action != 'refcustomer' && $object->brouillon)
-			print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=refcustomer&amp;id=' . $object->id . '">' . img_edit($langs->trans('Modify')) . '</a></td>';
-		print '</tr></table>';
-		print '</td><td colspan="3">';
-		if ($user->rights->commande->creer && $action == 'refcustomer') {
-			print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="post">';
-			print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">';
-			print '<input type="hidden" name="action" value="set_ref_client">';
-			print '<input type="text" class="flat" size="20" name="ref_client" value="' . $object->ref_client . '">';
-			print ' <input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
-			print '</form>';
-		} else {
-			print $object->ref_client;
-		}
-		print '</td>';
-		print '</tr>';
-
-		// Third party
-        print '<tr><td>';
-        print '<table class="nobordernopadding" width="100%">';
-        print '<tr><td>' . $langs->trans('Company') . '</td>';
-        print '</td><td colspan="5">';
-        if (! empty($conf->global->COMMANDE_CHANGE_THIRDPARTY) && $action != 'editthirdparty' && $object->brouillon && $user->rights->commande->creer)
-            print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editthirdparty&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetLinkToThirdParty'), 1) . '</a></td>';
-        print '</tr></table>';
-        print '</td><td colspan="5">';
-        if ($action == 'editthirdparty') {
-            $form->form_thirdparty($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, 'socid','client>0');
-        } else {
-            print $soc->getNomUrl(1, 'compta');
-        }
-		print '</tr>';*/
-
 		if ($soc->outstanding_limit)
 		{
 		    // Outstanding Bill
@@ -2295,29 +2245,6 @@ if ($action == 'create' && $user->rights->commande->creer)
 
     	// TODO How record was recorded OrderMode (llx_c_input_method)
 
-		// Project
-		/*
-		if (! empty($conf->projet->enabled))
-		{
-			$langs->load('projects');
-			print '<tr><td height="10">';
-			print '<table class="nobordernopadding" width="100%"><tr><td>';
-			print $langs->trans('Project');
-			print '</td>';
-			if ($action != 'classify')
-				print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->trans('SetProject')) . '</a></td>';
-			print '</tr></table>';
-			print '</td><td colspan="3">';
-			// print "$object->id, $object->socid, $object->fk_project";
-			if ($action == 'classify') {
-				$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1);
-			} else {
-				$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0);
-			}
-			print '</td></tr>';
-		}
-        */
-
 		// Incoterms
 		if (!empty($conf->incoterm->enabled))
 		{

文件差异内容过多而无法显示
+ 280 - 236
htdocs/compta/bank/card.php


+ 87 - 53
htdocs/compta/bank/class/account.class.php

@@ -38,7 +38,8 @@ class Account extends CommonObject
 {
     public $element = 'bank_account';
     public $table_element = 'bank_account';
-
+    public $picto = 'account';
+    
     /**
      * @var	int		Use id instead of rowid
      * @deprecated
@@ -500,9 +501,10 @@ class Account extends CommonObject
      *  Create bank account into database
      *
      *  @param	User	$user		Object user making creation
+     *  @param  int     $notrigger  1=Disable triggers
      *  @return int        			< 0 if KO, > 0 if OK
      */
-    function create(User $user = null)
+    function create(User $user = null, $notrigger=0)
     {
         global $langs,$conf, $hookmanager;
 
@@ -537,6 +539,8 @@ class Account extends CommonObject
 
         $now=dol_now();
 
+        $this->db->begin();
+        
         $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (";
         $sql.= "datec";
         $sql.= ", ref";
@@ -593,7 +597,7 @@ class Account extends CommonObject
         {
             $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."bank_account");
 
-            $result=$this->update($user);
+            $result=$this->update($user, 1);
             if ($result > 0)
             {
 				$accline = new AccountLine($this->db);
@@ -606,52 +610,68 @@ class Account extends CommonObject
 				$accline->fk_type = 'SOLD';
 
 				if ($accline->insert() < 0) {
-					return -3;
+					$error++;
 				}
 
-                // Actions on extra fields (by external module or standard code)
-                $hookmanager->initHooks(array('bankdao'));
-                $parameters=array('id'=>$this->id);
-                $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
-                if (empty($reshook))
+				if (! $error)
+				{
+				    $result=$this->insertExtraFields();
+				    if ($result < 0) $error++;
+				}
+                
+                if (! $error && ! $notrigger)
                 {
-                	if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
-                	{
-                		$result=$this->insertExtraFields();
-                		if ($result < 0)
-                		{
-                			return -4;
-                		}
-                	}
-                }
-                else if ($reshook < 0) return -5;
+                    // Call trigger
+                    $result=$this->call_trigger('BANKACCOUNT_CREATE',$user);
+                    if ($result < 0) $error++;
+                    // End call triggers
+                }        
+            }
+            else
+            {
+                $error++;
             }
-            return $this->id;
         }
         else
         {
             if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
             {
                 $this->error=$langs->trans("ErrorBankLabelAlreadyExists");
-                return -1;
+                $error++;
             }
             else {
                 $this->error=$this->db->error()." sql=".$sql;
-                return -2;
+                $error++;
             }
         }
+
+        if (! $error)
+        {
+            $this->db->commit();
+            return $this->id;
+        }
+        else
+        {
+            $this->db->rollback();
+            return -1*$error;
+        }
     }
 
     /**
      *    	Update bank account card
      *
      *    	@param	User	$user       Object user making action
+     *      @param  int     $notrigger  1=Disable triggers
      *		@return	int					<0 si ko, >0 si ok
      */
-    function update(User $user = null)
+    function update(User $user = null, $notrigger = 0)
     {
         global $langs,$conf, $hookmanager;
 
+        $error=0;
+        
+        $this->db->begin();
+        
         // Clean parameters
         $this->state_id = ($this->state_id?$this->state_id:$this->state_id);
         $this->country_id = ($this->country_id?$this->country_id:$this->country_id);
@@ -710,33 +730,41 @@ class Account extends CommonObject
         $result = $this->db->query($sql);
         if ($result)
         {
-
         	// Actions on extra fields (by external module or standard code)
-        	$hookmanager->initHooks(array('bankdao'));
-        	$parameters=array('id'=>$this->id);
-        	$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
-        	if (empty($reshook))
-        	{
-        		if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
-        		{
-        			$result=$this->insertExtraFields();
-        			if ($result < 0)
-        			{
-        				return -1;
-        			}
-        		}
-        	}
-        	else if ($reshook < 0) return -1;
-
-
-            return 1;
+    		if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+    		{
+    		    if (! $error)
+    		    {
+    		        $result=$this->insertExtraFields();
+    		        if ($result < 0) $error++;
+    		    }
+    		}
+    		
+    		if (! $error && ! $notrigger)
+    		{
+    		    // Call trigger
+    		    $result=$this->call_trigger('BANKACCOUNT_UPDATE',$user);
+    		    if ($result < 0) $error++;
+    		    // End call triggers
+    		}
         }
         else
         {
+            $error++;
             $this->error=$this->db->lasterror();
             dol_print_error($this->db);
-            return -1;
         }
+        
+		if (! $error)
+		{
+		    $this->db->commit();
+		    return $this->id;
+		}
+		else
+		{
+		    $this->db->rollback();
+		    return -1*$error;
+		}
     }
 
 
@@ -980,10 +1008,10 @@ class Account extends CommonObject
 
 
     /**
-     *    Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
+	 *  Return label of object status
      *
-     *    @param	int		$mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
-     *    @return   string        		Libelle
+	 *  @param      int		$mode			0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
+     *  @return     string        		    Label
      */
     function getLibStatut($mode=0)
     {
@@ -991,11 +1019,11 @@ class Account extends CommonObject
     }
 
     /**
-     *    Renvoi le libelle d'un statut donne
+     *  Return label of given object status
      *
-     *    @param	int		$statut        	Id statut
-     *    @param    int		$mode          	0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
-     *    @return   string        			Libelle du statut
+     *  @param	 int		$statut        	Id statut
+	 *  @param   int		$mode			0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
+     *  @return  string        			    Label
      */
 	function LibStatut($statut, $mode = 0)
 	{
@@ -1018,6 +1046,8 @@ class Account extends CommonObject
 			return $picto.' '.$label;
 		} elseif ($mode == 5) {
 			return $label.' '.$picto;
+		} elseif ($mode == 6) {
+		    return $label.' '.$picto;
 		}
 
 		//There is no short mode for this label
@@ -1368,11 +1398,12 @@ class Account extends CommonObject
 	 * - DeskCode
 	 *
 	 * Some countries show less or more bank account properties to the user
-	 *
+	 * 
+	 * @param  int     $includeibanbic         1=Return also key for IBAN and BIC
 	 * @return array
 	 * @see useDetailedBBAN
 	 */
-	public function getFieldsToShow()
+	public function getFieldsToShow($includeibanbic=0)
 	{
 		//Get the required properties depending on the country
 		$detailedBBAN = $this->useDetailedBBAN();
@@ -1391,8 +1422,11 @@ class Account extends CommonObject
 		}
 
 		//if ($this->needIBAN()) {    // return always IBAN and BIC (this was old behaviour)
+		if ($includeibanbic)
+		{
 			$fieldarray[]='IBAN';
 			$fieldarray[]='BIC';
+		}
 		//}
 
 		//Get the order the properties are shown
@@ -1621,7 +1655,7 @@ class AccountLine extends CommonObject
 		$sql .= ", '".$this->db->idate($this->datev)."'";
 		$sql .= ", '".$this->db->escape($this->label)."'";
 		$sql .= ", ".price2num($this->amount);
-		$sql .= ", '".$this->fk_user_author."'";
+		$sql .= ", ".($this->fk_user_author > 0 ? "'".$this->fk_user_author."'":"null");
 		$sql .= ", ".($this->num_chq ? "'".$this->num_chq."'" : "null");
 		$sql .= ", '".$this->fk_account."'";
 		$sql .= ", '".$this->db->escape($this->fk_type)."'";

+ 1 - 1
htdocs/core/class/commoninvoice.class.php

@@ -217,7 +217,7 @@ abstract class CommonInvoice extends CommonObject
 	/**
 	 *  Return label of object status
 	 *
-	 *  @param      int		$mode			0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto
+	 *  @param      int		$mode			0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto
 	 *  @param      integer	$alreadypaid    0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
 	 *  @return     string			        Label
 	 */

部分文件因为文件数量过多而无法显示