ソースを参照

Fixing style errors.

stickler-ci 3 年 前
コミット
2d9e303abf

+ 24 - 24
htdocs/asset/admin/setup.php

@@ -46,7 +46,7 @@ $scandir = GETPOST('scan_dir', 'alpha');
 $type = 'asset';
 
 $arrayofparameters = array(
-    'ASSET_ACCOUNTANCY_CATEGORY'=>array('type'=>'accountancy_category', 'enabled'=>1),
+	'ASSET_ACCOUNTANCY_CATEGORY'=>array('type'=>'accountancy_category', 'enabled'=>1),
 	//'ASSET_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1),
 	//'ASSET_MYPARAM2'=>array('type'=>'textarea','enabled'=>1),
 	//'ASSET_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1),
@@ -548,29 +548,29 @@ if ($action == 'edit') {
 				} else {
 					print '<input name="' . $constname . '" class="maxwidth200" value="' . dol_escape_htmltag($selected) . '">';
 				}
-            } elseif ($val['type'] == 'accountancy_category') {
-                $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
-                if (!empty($conf->accounting->enabled)) {
-                    print '<input type="text" name="' . $constname . '" list="pcg_type_datalist" value="' . $selected . '">';
-                    // autosuggest from existing account types if found
-                    print '<datalist id="pcg_type_datalist">';
-                    require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
-                    $accountsystem = new AccountancySystem($db);
-                    $accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
-                    $sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account';
-                    $sql .= " WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) . "'";
-                    $sql .= ' AND entity in ('.getEntity('accounting_account', 0).')';		// Always limit to current entity. No sharing in accountancy.
-                    $sql .= ' LIMIT 50000'; // just as a sanity check
-                    $resql = $db->query($sql);
-                    if ($resql) {
-                        while ($obj = $db->fetch_object($resql)) {
-                            print '<option value="' . dol_escape_htmltag($obj->pcg_type) . '">';
-                        }
-                    }
-                    print '</datalist>';
-                } else {
-                    print '<input name="' . $constname . '" class="maxwidth200" value="' . dol_escape_htmltag($selected) . '">';
-                }
+			} elseif ($val['type'] == 'accountancy_category') {
+				$selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname);
+				if (!empty($conf->accounting->enabled)) {
+					print '<input type="text" name="' . $constname . '" list="pcg_type_datalist" value="' . $selected . '">';
+					// autosuggest from existing account types if found
+					print '<datalist id="pcg_type_datalist">';
+					require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancysystem.class.php';
+					$accountsystem = new AccountancySystem($db);
+					$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
+					$sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account';
+					$sql .= " WHERE fk_pcg_version = '" . $db->escape($accountsystem->ref) . "'";
+					$sql .= ' AND entity in ('.getEntity('accounting_account', 0).')';		// Always limit to current entity. No sharing in accountancy.
+					$sql .= ' LIMIT 50000'; // just as a sanity check
+					$resql = $db->query($sql);
+					if ($resql) {
+						while ($obj = $db->fetch_object($resql)) {
+							print '<option value="' . dol_escape_htmltag($obj->pcg_type) . '">';
+						}
+					}
+					print '</datalist>';
+				} else {
+					print '<input name="' . $constname . '" class="maxwidth200" value="' . dol_escape_htmltag($selected) . '">';
+				}
 			} else {
 				print '<input name="'.$constname.'"  class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->{$constname}.'">';
 			}

+ 1 - 1
htdocs/asset/card.php

@@ -293,7 +293,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('AssetConfirmReOpenAsk', $object->ref), 'confirm_reopen', $formquestion, 'yes', 1);
 	}
 	// Clone confirmation
-/*	elseif ($action == 'clone') {
+	/*  elseif ($action == 'clone') {
 		// Create an array for form
 		$formquestion = array();
 		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);

+ 158 - 158
htdocs/asset/class/asset.class.php

@@ -258,89 +258,89 @@ class Asset extends CommonObject
 
 		dol_syslog(__METHOD__, LOG_DEBUG);
 
-//		$object = new self($this->db);
-//
-//		$this->db->begin();
-//
-//		// Load source object
-//		$result = $object->fetchCommon($fromid);
-//		if ($result > 0 && !empty($object->table_element_line)) {
-//			$object->fetchLines();
-//		}
-//
-//		// get lines so they will be clone
-//		//foreach($this->lines as $line)
-//		//	$line->fetch_optionals();
-//
-//		// Reset some properties
-//		unset($object->id);
-//		unset($object->fk_user_creat);
-//		unset($object->import_key);
-//
-//		// Clear fields
-//		if (property_exists($object, 'ref')) {
-//			$object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
-//		}
-//		if (property_exists($object, 'label')) {
-//			$object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
-//		}
-//		if (property_exists($object, 'status')) {
-//			$object->status = self::STATUS_DRAFT;
-//		}
-//		if (property_exists($object, 'date_creation')) {
-//			$object->date_creation = dol_now();
-//		}
-//		if (property_exists($object, 'date_modification')) {
-//			$object->date_modification = null;
-//		}
-//		// ...
-//		// Clear extrafields that are unique
-//		if (is_array($object->array_options) && count($object->array_options) > 0) {
-//			$extrafields->fetch_name_optionals_label($this->table_element);
-//			foreach ($object->array_options as $key => $option) {
-//				$shortkey = preg_replace('/options_/', '', $key);
-//				if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
-//					//var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
-//					unset($object->array_options[$key]);
-//				}
-//			}
-//		}
-//
-//		// Create clone
-//		$object->context['createfromclone'] = 'createfromclone';
-//		$result = $object->createCommon($user);
-//		if ($result < 0) {
-//			$error++;
-//			$this->error = $object->error;
-//			$this->errors = $object->errors;
-//		}
-//
-//		if (!$error) {
-//			// copy internal contacts
-//			if ($this->copy_linked_contact($object, 'internal') < 0) {
-//				$error++;
-//			}
-//		}
-//
-//		if (!$error) {
-//			// copy external contacts if same company
-//			if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
-//				if ($this->copy_linked_contact($object, 'external') < 0) {
-//					$error++;
-//				}
-//			}
-//		}
-//
-//		unset($object->context['createfromclone']);
-//
-//		// End
-//		if (!$error) {
-//			$this->db->commit();
-//			return $object;
-//		} else {
-//			$this->db->rollback();
-//			return -1;
-//		}
+		//      $object = new self($this->db);
+		//
+		//      $this->db->begin();
+		//
+		//      // Load source object
+		//      $result = $object->fetchCommon($fromid);
+		//      if ($result > 0 && !empty($object->table_element_line)) {
+		//          $object->fetchLines();
+		//      }
+		//
+		//      // get lines so they will be clone
+		//      //foreach($this->lines as $line)
+		//      //  $line->fetch_optionals();
+		//
+		//      // Reset some properties
+		//      unset($object->id);
+		//      unset($object->fk_user_creat);
+		//      unset($object->import_key);
+		//
+		//      // Clear fields
+		//      if (property_exists($object, 'ref')) {
+		//          $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
+		//      }
+		//      if (property_exists($object, 'label')) {
+		//          $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
+		//      }
+		//      if (property_exists($object, 'status')) {
+		//          $object->status = self::STATUS_DRAFT;
+		//      }
+		//      if (property_exists($object, 'date_creation')) {
+		//          $object->date_creation = dol_now();
+		//      }
+		//      if (property_exists($object, 'date_modification')) {
+		//          $object->date_modification = null;
+		//      }
+		//      // ...
+		//      // Clear extrafields that are unique
+		//      if (is_array($object->array_options) && count($object->array_options) > 0) {
+		//          $extrafields->fetch_name_optionals_label($this->table_element);
+		//          foreach ($object->array_options as $key => $option) {
+		//              $shortkey = preg_replace('/options_/', '', $key);
+		//              if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
+		//                  //var_dump($key); var_dump($clonedObj->array_options[$key]); exit;
+		//                  unset($object->array_options[$key]);
+		//              }
+		//          }
+		//      }
+		//
+		//      // Create clone
+		//      $object->context['createfromclone'] = 'createfromclone';
+		//      $result = $object->createCommon($user);
+		//      if ($result < 0) {
+		//          $error++;
+		//          $this->error = $object->error;
+		//          $this->errors = $object->errors;
+		//      }
+		//
+		//      if (!$error) {
+		//          // copy internal contacts
+		//          if ($this->copy_linked_contact($object, 'internal') < 0) {
+		//              $error++;
+		//          }
+		//      }
+		//
+		//      if (!$error) {
+		//          // copy external contacts if same company
+		//          if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
+		//              if ($this->copy_linked_contact($object, 'external') < 0) {
+		//                  $error++;
+		//              }
+		//          }
+		//      }
+		//
+		//      unset($object->context['createfromclone']);
+		//
+		//      // End
+		//      if (!$error) {
+		//          $this->db->commit();
+		//          return $object;
+		//      } else {
+		//          $this->db->rollback();
+		//          return -1;
+		//      }
 		return -1;
 	}
 
@@ -656,7 +656,7 @@ class Asset extends CommonObject
 		$sql .= " WHERE doc_type = 'asset'";
 		$sql .= ")";
 		$sql .= "SELECT ad.rowid, ad.depreciation_mode, ad.ref, ad.depreciation_date, ad.depreciation_ht, ad.cumulative_depreciation_ht";
-		$sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1 , 0) . " AS bookkeeping";
+		$sql .= ", " . $this->db->ifsql('iab.fk_docdet IS NOT NULL', 1, 0) . " AS bookkeeping";
 		$sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation AS ad";
 		$sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid";
 		$sql .= " WHERE ad.fk_asset = " . $this->id;
@@ -766,12 +766,12 @@ class Asset extends CommonObject
 
 		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "asset_depreciation(fk_asset, depreciation_mode, ref, depreciation_date, depreciation_ht, cumulative_depreciation_ht, accountancy_code_debit, accountancy_code_credit)";
 		$sql .= " VALUES ( ";
-		$sql .= " " . (int)$this->id;
+		$sql .= " " . (int) $this->id;
 		$sql .= ", '" . $this->db->escape($mode) . "'";
 		$sql .= ", '" . $this->db->escape($ref) . "'";
 		$sql .= ", '" . $this->db->idate($depreciation_date) . "'";
-		$sql .= ", " . (double)$depreciation_ht;
-		$sql .= ", " . (double)$cumulative_depreciation_ht;
+		$sql .= ", " . (double) $depreciation_ht;
+		$sql .= ", " . (double) $cumulative_depreciation_ht;
 		$sql .= ", '" . $this->db->escape($accountancy_code_debit) . "'";
 		$sql .= ", '" . $this->db->escape($accountancy_code_credit) . "'";
 		$sql .= ")";
@@ -919,18 +919,18 @@ class Asset extends CommonObject
 				$depreciation_date_start = $this->date_start > $this->date_acquisition ? $this->date_start : $this->date_acquisition;
 				$depreciation_date_end = dol_time_plus_duree($depreciation_date_start, $fields['duration'], $fields['duration_type'] == 1 ? 'm' : ($fields['duration_type'] == 2 ? 'd' : 'y'));
 				$depreciation_amount = $fields['amount_base_depreciation_ht'];
-                if ($fields['duration_type'] == 2) { // Daily
-                    $fiscal_period_start = $depreciation_date_start;
-                    $fiscal_period_end = $depreciation_date_start;
-                } elseif ($fields['duration_type'] == 1) { // Monthly
-                    $date_temp = dol_getdate($depreciation_date_start);
-                    $fiscal_period_start = dol_get_first_day($date_temp['year'], $date_temp['mon'], false);
-                    $fiscal_period_end = dol_get_last_day($date_temp['year'], $date_temp['mon'], false);
-                } else { // Annually
-                    $fiscal_period_start = $init_fiscal_period_start;
-                    $fiscal_period_end = $init_fiscal_period_end;
-                }
-                $cumulative_depreciation_ht = $last_cumulative_depreciation_ht;
+				if ($fields['duration_type'] == 2) { // Daily
+					$fiscal_period_start = $depreciation_date_start;
+					$fiscal_period_end = $depreciation_date_start;
+				} elseif ($fields['duration_type'] == 1) { // Monthly
+					$date_temp = dol_getdate($depreciation_date_start);
+					$fiscal_period_start = dol_get_first_day($date_temp['year'], $date_temp['mon'], false);
+					$fiscal_period_end = dol_get_last_day($date_temp['year'], $date_temp['mon'], false);
+				} else { // Annually
+					$fiscal_period_start = $init_fiscal_period_start;
+					$fiscal_period_end = $init_fiscal_period_end;
+				}
+				$cumulative_depreciation_ht = $last_cumulative_depreciation_ht;
 				$depreciation_period_amount = $depreciation_amount - $this->reversal_amount_ht;
 				$start_date = $depreciation_date_start;
 				$disposal_date = isset($this->disposal_date) && $this->disposal_date !== "" ? $this->disposal_date : "";
@@ -972,12 +972,12 @@ class Asset extends CommonObject
 				// futures depreciation lines
 				//-----------------------------------------------------
 				$nb_days_in_year = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_YEAR : 360;
-                $nb_days_in_month = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH : 30;
-                $period_amount = (double) price2num($depreciation_period_amount / $fields['duration'], 'MT');
-                $first_period_found = false;
+				$nb_days_in_month = !empty($conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH) ? $conf->global->ASSET_DEPRECIATION_DURATION_PER_MONTH : 30;
+				$period_amount = (double) price2num($depreciation_period_amount / $fields['duration'], 'MT');
+				$first_period_found = false;
 				$first_period_date = isset($begin_period) && $begin_period > $fiscal_period_start ? $begin_period : $fiscal_period_start;
 
-                $ref_date_format = "%Y" . ($fields['duration_type'] == 1 || $fields['duration_type'] == 2 ? '-%m' : '') . ($fields['duration_type'] == 2 ? '-%d' : '');
+				$ref_date_format = "%Y" . ($fields['duration_type'] == 1 || $fields['duration_type'] == 2 ? '-%m' : '') . ($fields['duration_type'] == 2 ? '-%d' : '');
 
 				// Loop security
 				$idx_loop = 0;
@@ -995,8 +995,8 @@ class Asset extends CommonObject
 
 						$first_period_found = true;
 
-                        $period_begin = dol_print_date($fiscal_period_start, $ref_date_format);
-                        $period_end = dol_print_date($fiscal_period_end, $ref_date_format);
+						$period_begin = dol_print_date($fiscal_period_start, $ref_date_format);
+						$period_end = dol_print_date($fiscal_period_end, $ref_date_format);
 						$ref = $period_begin . ($period_begin != $period_end ? ' - ' . $period_end : '');
 						if ($fiscal_period_start <= $disposal_date && $disposal_date <= $fiscal_period_end) {
 							$ref .= ' - ' . $langs->transnoentitiesnoconv('AssetDisposal');
@@ -1004,24 +1004,24 @@ class Asset extends CommonObject
 
 						$begin_date = $fiscal_period_start < $start_date && $start_date <= $fiscal_period_end ? $start_date : $fiscal_period_start;
 						$end_date = $fiscal_period_start < $finish_date && $finish_date <= $fiscal_period_end ? $finish_date : $fiscal_period_end;
-                        if ($fields['duration_type'] == 2) { // Daily
-                            $depreciation_ht = $period_amount;
-                        } elseif ($fields['duration_type'] == 1) { // Monthly
-                            $nb_days = min($nb_days_in_month, num_between_day($begin_date, $end_date, 1));
-                            if ($nb_days >= 28) {
-                                $date_temp = dol_getdate($begin_date);
-                                if ($date_temp['mon'] == 2) {
-                                    $nb_days = 30;
-                                }
-                            }
-                            $depreciation_ht = (double) price2num($period_amount * $nb_days / $nb_days_in_month, 'MT');
-                        } else { // Annually
-                            $nb_days = min($nb_days_in_year, num_between_day($begin_date, $end_date, 1));
-                            $depreciation_ht = (double) price2num($period_amount * $nb_days / $nb_days_in_year, 'MT');
-                        }
-
-                        if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) { // last period
-							$depreciation_ht = (double)price2num($depreciation_amount - $cumulative_depreciation_ht, 'MT');
+						if ($fields['duration_type'] == 2) { // Daily
+							$depreciation_ht = $period_amount;
+						} elseif ($fields['duration_type'] == 1) { // Monthly
+							$nb_days = min($nb_days_in_month, num_between_day($begin_date, $end_date, 1));
+							if ($nb_days >= 28) {
+								$date_temp = dol_getdate($begin_date);
+								if ($date_temp['mon'] == 2) {
+									$nb_days = 30;
+								}
+							}
+							$depreciation_ht = (double) price2num($period_amount * $nb_days / $nb_days_in_month, 'MT');
+						} else { // Annually
+							$nb_days = min($nb_days_in_year, num_between_day($begin_date, $end_date, 1));
+							$depreciation_ht = (double) price2num($period_amount * $nb_days / $nb_days_in_year, 'MT');
+						}
+
+						if ($fiscal_period_start <= $depreciation_date_end && $depreciation_date_end <= $fiscal_period_end) { // last period
+							$depreciation_ht = (double) price2num($depreciation_amount - $cumulative_depreciation_ht, 'MT');
 							$cumulative_depreciation_ht = $depreciation_amount;
 						} else {
 							$cumulative_depreciation_ht += $depreciation_ht;
@@ -1034,15 +1034,15 @@ class Asset extends CommonObject
 						}
 					}
 
-                    // Next fiscal period (+1 day/month/year)
+					// Next fiscal period (+1 day/month/year)
 					$fiscal_period_start = dol_time_plus_duree($fiscal_period_end, 1, 'd');
-                    if ($fields['duration_type'] == 2) { // Daily
-                        $fiscal_period_end = $fiscal_period_start;
-                    } elseif ($fields['duration_type'] == 1) { // Monthly
-                        $fiscal_period_end = dol_time_plus_duree(dol_time_plus_duree($fiscal_period_start, 1, 'm'), -1, 'd');
-                    } else { // Annually
-                        $fiscal_period_end = dol_time_plus_duree(dol_time_plus_duree($fiscal_period_start, 1, 'y'), -1, 'd');
-                    }
+					if ($fields['duration_type'] == 2) { // Daily
+						$fiscal_period_end = $fiscal_period_start;
+					} elseif ($fields['duration_type'] == 1) { // Monthly
+						$fiscal_period_end = dol_time_plus_duree(dol_time_plus_duree($fiscal_period_start, 1, 'm'), -1, 'd');
+					} else { // Annually
+						$fiscal_period_end = dol_time_plus_duree(dol_time_plus_duree($fiscal_period_start, 1, 'y'), -1, 'd');
+					}
 					$last_period_date = $disposal_date !== "" && $disposal_date < $depreciation_date_end ? $disposal_date : $depreciation_date_end;
 				} while ($fiscal_period_start < $last_period_date);
 
@@ -1561,31 +1561,31 @@ class Asset extends CommonObject
 	 *  @param      null|array  $moreparams     Array to provide more information
 	 *  @return     int         				0 if KO, 1 if OK
 	 */
-//	public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
-//	{
-//		global $conf, $langs;
-//
-//		$result = 0;
-//		$includedocgeneration = 1;
-//
-//		$langs->load("asset@asset");
-//
-//		if (!dol_strlen($modele)) {
-//			$modele = 'standard_asset';
-//
-//			if (!empty($this->model_pdf)) {
-//				$modele = $this->model_pdf;
-//			} elseif (!empty($conf->global->ASSET_ADDON_PDF)) {
-//				$modele = $conf->global->ASSET_ADDON_PDF;
-//			}
-//		}
-//
-//		$modelpath = "core/modules/asset/doc/";
-//
-//		if ($includedocgeneration && !empty($modele)) {
-//			$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
-//		}
-//
-//		return $result;
-//	}
+	//  public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
+	//  {
+	//      global $conf, $langs;
+	//
+	//      $result = 0;
+	//      $includedocgeneration = 1;
+	//
+	//      $langs->load("asset@asset");
+	//
+	//      if (!dol_strlen($modele)) {
+	//          $modele = 'standard_asset';
+	//
+	//          if (!empty($this->model_pdf)) {
+	//              $modele = $this->model_pdf;
+	//          } elseif (!empty($conf->global->ASSET_ADDON_PDF)) {
+	//              $modele = $conf->global->ASSET_ADDON_PDF;
+	//          }
+	//      }
+	//
+	//      $modelpath = "core/modules/asset/doc/";
+	//
+	//      if ($includedocgeneration && !empty($modele)) {
+	//          $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
+	//      }
+	//
+	//      return $result;
+	//  }
 }

+ 25 - 25
htdocs/asset/class/assetdepreciationoptions.class.php

@@ -80,13 +80,13 @@ class AssetDepreciationOptions extends CommonObject
 				'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',),
 				'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'economic:depreciation_type:1'),
 				'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
-                'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
-                'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("economic")',),
-                'accelerated_depreciation_option' => array('type'=>'boolean', 'label'=>'AssetDepreciationOptionAcceleratedDepreciation', 'enabled'=>'1', 'position'=>60, 'column_break' => true, 'notnull'=>0, 'default'=>'0', 'visible'=>1, 'validate'=>'1',),
-                'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',),
-                'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>100, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
-                'total_amount_last_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>110, 'noteditable'=> 1, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
-            ),
+				'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
+				'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("economic")',),
+				'accelerated_depreciation_option' => array('type'=>'boolean', 'label'=>'AssetDepreciationOptionAcceleratedDepreciation', 'enabled'=>'1', 'position'=>60, 'column_break' => true, 'notnull'=>0, 'default'=>'0', 'visible'=>1, 'validate'=>'1',),
+				'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',),
+				'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>100, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
+				'total_amount_last_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionTotalAmountLastDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>110, 'noteditable'=> 1, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
+			),
 		),
 		'accelerated_depreciation' => array(
 			'label' => 'AssetDepreciationOptionAcceleratedDepreciation',
@@ -96,7 +96,7 @@ class AssetDepreciationOptions extends CommonObject
 				'depreciation_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDepreciationType', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDepreciationTypeLinear', '1'=>'AssetDepreciationOptionDepreciationTypeDegressive', '2'=>'AssetDepreciationOptionDepreciationTypeExceptional'), 'validate'=>'1',),
 				'degressive_coefficient' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionDegressiveRate', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1','enabled_field' => 'accelerated_depreciation:depreciation_type:1'),
 				'duration' => array('type'=>'integer', 'label'=>'AssetDepreciationOptionDuration', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
-                'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
+				'duration_type' => array('type'=>'smallint', 'label'=>'AssetDepreciationOptionDurationType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'arrayofkeyval'=>array('0'=>'AssetDepreciationOptionDurationTypeAnnual', '1'=>'AssetDepreciationOptionDurationTypeMonthly'/*, '2'=>'AssetDepreciationOptionDurationTypeDaily'*/), 'validate'=>'1',),
 				'rate' => array('type'=>'double(24,8)', 'label'=>'AssetDepreciationOptionRate', 'enabled'=>'1', 'position'=>50, 'visible'=>3, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1', 'computed' => '$object->asset_depreciation_options->getRate("accelerated_depreciation")',),
 				'amount_base_depreciation_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDepreciationHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>80, 'column_break' => true, 'notnull'=>0, 'required'=>1, 'visible'=>1, 'default'=>'$object->reversal_amount_ht > 0 ? $object->reversal_amount_ht : $object->acquisition_value_ht', 'isameasure'=>'1', 'validate'=>'1',),
 				'amount_base_deductible_ht' => array('type'=>'price', 'label'=>'AssetDepreciationOptionAmountBaseDeductibleHT', 'enabled'=>'isset($object)&&get_class($object)=="Asset"', 'only_on_asset'=>1, 'position'=>90, 'notnull'=>0, 'visible'=>1, 'default'=>'0', 'isameasure'=>'1', 'validate'=>'1',),
@@ -262,9 +262,9 @@ class AssetDepreciationOptions extends CommonObject
 				$field_value = $value;
 				if ($field_info['notnull'] > 0 && $field_value == '' && !is_null($field_info['default']) && $field_info['default'] == '(PROV)') {
 					$field_value = '(PROV)';
-                } elseif ((!empty($field_info['required']) || $field_info['notnull'] > 0) && $field_value == '' && !empty($field_info['default'])) {
-                    $field_value = dol_eval($field_info['default'], 1);
-                }
+				} elseif ((!empty($field_info['required']) || $field_info['notnull'] > 0) && $field_value == '' && !empty($field_info['default'])) {
+					$field_value = dol_eval($field_info['default'], 1);
+				}
 				if ($field_info['notnull'] > 0 && $field_value == '' && is_null($field_info['default'])) {
 					$error++;
 					setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($field_info['label'])), null, 'errors');
@@ -412,7 +412,7 @@ class AssetDepreciationOptions extends CommonObject
 			'base_depreciation_ht' => $this->deprecation_options[$mode]['amount_base_depreciation_ht'],
 			'duration' => $this->deprecation_options[$mode]['duration'],
 			'duration_type' => $duration_type_list[$this->deprecation_options[$mode]['duration_type']],
-            'rate' => $this->getRate($mode),
+			'rate' => $this->getRate($mode),
 		);
 	}
 
@@ -530,17 +530,17 @@ class AssetDepreciationOptions extends CommonObject
 		}
 	}
 
-    /**
-     *  Get rate
-     *
-     * @param	string			$mode		Depreciation mode (economic, accelerated_depreciation, ...)
-     * @return	string						Rate of the provided mode option
-     */
-    public function getRate($mode)
-    {
-        $duration = $this->deprecation_options[$mode]["duration"] > 0 ? $this->deprecation_options[$mode]["duration"] : 0;
-        $duration_type = $this->deprecation_options[$mode]["duration_type"] > 0 ? $this->deprecation_options[$mode]["duration_type"] : 0;
-
-        return price(price2num($duration > 0 ? (100 * ($duration_type == 1 ? 12 : 1) / $duration) : 0, 2));
-    }
+	/**
+	 *  Get rate
+	 *
+	 * @param	string			$mode		Depreciation mode (economic, accelerated_depreciation, ...)
+	 * @return	string						Rate of the provided mode option
+	 */
+	public function getRate($mode)
+	{
+		$duration = $this->deprecation_options[$mode]["duration"] > 0 ? $this->deprecation_options[$mode]["duration"] : 0;
+		$duration_type = $this->deprecation_options[$mode]["duration_type"] > 0 ? $this->deprecation_options[$mode]["duration_type"] : 0;
+
+		return price(price2num($duration > 0 ? (100 * ($duration_type == 1 ? 12 : 1) / $duration) : 0, 2));
+	}
 }

+ 4 - 4
htdocs/asset/class/assetmodel.class.php

@@ -105,8 +105,8 @@ class AssetModel extends CommonObject
 		'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1'),
 		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'showoncombobox'=>'2', 'validate'=>'1',),
 		'asset_type' => array('type'=>'smallint', 'label'=>'AssetType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'AssetTypeIntangible', '1'=>'AssetTypeTangible', '2'=>'AssetTypeInProgress', '3'=>'AssetTypeFinancial'), 'validate'=>'1',),
-        'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>1, 'position'=>50),
-        'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
+		'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>1, 'position'=>50),
+		'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
 		'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>301, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',),
 		'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
 		'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
@@ -461,9 +461,9 @@ class AssetModel extends CommonObject
 			$sql .= ", date_validation = '" . $this->db->idate($now) . "'";
 		}
 		if (!empty($this->fields['fk_user_valid'])) {
-			$sql .= ", fk_user_valid = " . ((int)$user->id);
+			$sql .= ", fk_user_valid = " . ((int) $user->id);
 		}
-		$sql .= " WHERE rowid = " . ((int)$this->id);
+		$sql .= " WHERE rowid = " . ((int) $this->id);
 
 		dol_syslog(get_class($this) . "::validate()", LOG_DEBUG);
 		$resql = $this->db->query($sql);

+ 2 - 2
htdocs/asset/document.php

@@ -142,9 +142,9 @@ if ($object->id) {
 
 	$modulepart = 'asset';
 	$permissiontoadd = $user->rights->asset->write;
-//	$permissiontoadd = 1;
+	//  $permissiontoadd = 1;
 	$permtoedit = $user->rights->asset->write;
-//	$permtoedit = 1;
+	//  $permtoedit = 1;
 	$param = '&id=' . $object->id;
 
 	//$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/';

+ 26 - 26
htdocs/asset/model/agenda.php

@@ -181,35 +181,35 @@ if ($object->id > 0) {
 
 	print '<div class="tabsAction">';
 
-//	if (!empty($conf->agenda->enabled)) {
-//		if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
-//			print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '">' . $langs->trans("AddAction") . '</a>';
-//		} else {
-//			print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AddAction") . '</a>';
-//		}
-//	}
+	//  if (!empty($conf->agenda->enabled)) {
+	//      if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) {
+	//          print '<a class="butAction" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create' . $out . '">' . $langs->trans("AddAction") . '</a>';
+	//      } else {
+	//          print '<a class="butActionRefused classfortooltip" href="#">' . $langs->trans("AddAction") . '</a>';
+	//      }
+	//  }
 
 	print '</div>';
 
-//	if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
-//		$param = '&id=' . $object->id . '&socid=' . $socid;
-//		if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
-//			$param .= '&contextpage=' . urlencode($contextpage);
-//		}
-//		if ($limit > 0 && $limit != $conf->liste_limit) {
-//			$param .= '&limit=' . urlencode($limit);
-//		}
-//
-//
-//		print load_fiche_titre($langs->trans("ActionsOnAssetModel"), '', '');
-//
-//		// List of all actions
-//		$filters = array();
-//		$filters['search_agenda_label'] = $search_agenda_label;
-//
-//		// TODO Replace this with same code than into list.php
-//		show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
-//	}
+	//  if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
+	//      $param = '&id=' . $object->id . '&socid=' . $socid;
+	//      if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+	//          $param .= '&contextpage=' . urlencode($contextpage);
+	//      }
+	//      if ($limit > 0 && $limit != $conf->liste_limit) {
+	//          $param .= '&limit=' . urlencode($limit);
+	//      }
+	//
+	//
+	//      print load_fiche_titre($langs->trans("ActionsOnAssetModel"), '', '');
+	//
+	//      // List of all actions
+	//      $filters = array();
+	//      $filters['search_agenda_label'] = $search_agenda_label;
+	//
+	//      // TODO Replace this with same code than into list.php
+	//      show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
+	//  }
 }
 
 // End of page

+ 8 - 8
htdocs/asset/model/card.php

@@ -313,14 +313,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	print '</div><div class="fichehalfright">';
 
-//	$MAXEVENT = 10;
-//
-//	$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id);
-//
-//	// List of actions on element
-//	include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
-//	$formactions = new FormActions($db);
-//	$somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, 0, 1, '', $MAXEVENT, '', $morehtmlright);
+	//  $MAXEVENT = 10;
+	//
+	//  $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT . '/asset/model/agenda.php?id=' . $object->id);
+	//
+	//  // List of actions on element
+	//  include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
+	//  $formactions = new FormActions($db);
+	//  $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, 0, 1, '', $MAXEVENT, '', $morehtmlright);
 
 	print '</div></div>';
 }

+ 5 - 5
htdocs/asset/model/list.php

@@ -81,10 +81,10 @@ if (!$sortorder) {
 $search_all = GETPOST('search_all', 'alphanohtml');
 $search = array();
 foreach ($object->fields as $key => $val) {
-    if ($key == 'fk_pays' && !GETPOSTISSET('search_'.$key)) {
-        $search[$key] = $mysoc->country_id;
-    } elseif (GETPOST('search_'.$key, 'alpha') !== '') {
-        $search[$key] = GETPOST('search_'.$key, 'alpha');
+	if ($key == 'fk_pays' && !GETPOSTISSET('search_'.$key)) {
+		$search[$key] = $mysoc->country_id;
+	} elseif (GETPOST('search_'.$key, 'alpha') !== '') {
+		$search[$key] = GETPOST('search_'.$key, 'alpha');
 	}
 	if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
 		$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
@@ -166,7 +166,7 @@ if (empty($reshook)) {
 	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
 		foreach ($object->fields as $key => $val) {
 			$search[$key] = '';
-            if ($key == 'fk_pays') $search[$key] = $mysoc->country_id;
+			if ($key == 'fk_pays') $search[$key] = $mysoc->country_id;
 			if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
 				$search[$key.'_dtstart'] = '';
 				$search[$key.'_dtend'] = '';

+ 3 - 3
htdocs/asset/tpl/depreciation_options_edit.tpl.php

@@ -114,8 +114,8 @@ if (empty($reshook)) {
 			}
 
 			$more_class = '';
-            if (!empty($field_info['required']) || (isset($field_info['notnull']) && $field_info['notnull'] > 0)) {
-                $more_class .= ' fieldrequired';
+			if (!empty($field_info['required']) || (isset($field_info['notnull']) && $field_info['notnull'] > 0)) {
+				$more_class .= ' fieldrequired';
 			}
 			if (preg_match('/^(text|html)/', $val['type'])) {
 				$more_class .= ' tdtop';
@@ -146,7 +146,7 @@ if (empty($reshook)) {
 				}
 				$value = GETPOSTISSET($html_name) ? GETPOST($html_name, $check) : $assetdepreciationoptions->$field_key;
 			} elseif ($field_info['type'] == 'price') {
-                $value = GETPOSTISSET($html_name) ? price2num(GETPOST($html_name)) : ($assetdepreciationoptions->$field_key ? price2num($assetdepreciationoptions->$field_key) : (!empty($field_info['default']) ? dol_eval($field_info['default'], 1) : 0));
+				$value = GETPOSTISSET($html_name) ? price2num(GETPOST($html_name)) : ($assetdepreciationoptions->$field_key ? price2num($assetdepreciationoptions->$field_key) : (!empty($field_info['default']) ? dol_eval($field_info['default'], 1) : 0));
 			} elseif ($field_key == 'lang') {
 				$value = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : $assetdepreciationoptions->lang;
 			} else {