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

This commit is contained in:
Laurent Destailleur 2016-11-22 19:45:38 +01:00
commit f4fb07b570
11 changed files with 206 additions and 102 deletions

View File

@ -216,7 +216,7 @@ $parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
$sql.=$hookmanager->resPrint; $sql.=$hookmanager->resPrint;
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; $sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (u.rowid = ef.fk_object)"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."mytable_extrafields as ef on (t.rowid = ef.fk_object)";
$sql.= " WHERE 1 = 1"; $sql.= " WHERE 1 = 1";
//$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")"; //$sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
if ($search_field1) $sql.= natural_search("field1",$search_field1); if ($search_field1) $sql.= natural_search("field1",$search_field1);

View File

@ -1034,9 +1034,9 @@ if ($id)
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; } if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); } if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); }
if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); } if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); }
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $valuetoshow=''; } if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $valuetoshow=''; }
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); } if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); }
@ -1052,6 +1052,18 @@ if ($id)
if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); }
if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); }
if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); }
if ($fieldlist[$field]=='paper_size') { $valuetoshow=$langs->trans("PaperSize"); }
if ($fieldlist[$field]=='orientation') { $valuetoshow=$langs->trans("Orientation"); }
if ($fieldlist[$field]=='leftmargin') { $valuetoshow=$langs->trans("LeftMargin"); }
if ($fieldlist[$field]=='topmargin') { $valuetoshow=$langs->trans("TopMargin"); }
if ($fieldlist[$field]=='spacex') { $valuetoshow=$langs->trans("SpaceX"); }
if ($fieldlist[$field]=='spacey') { $valuetoshow=$langs->trans("SpaceY"); }
if ($fieldlist[$field]=='font_size') { $valuetoshow=$langs->trans("FontSize"); }
if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); }
if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); }
if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); }
if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); }
if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("Info"); }
if ($id == 2) // Special cas for state page if ($id == 2) // Special cas for state page
{ {
@ -1211,9 +1223,9 @@ if ($id)
if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); } if ($fieldlist[$field]=='nbjour') { $valuetoshow=$langs->trans("NbOfDays"); }
if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; } if ($fieldlist[$field]=='type_cdr') { $valuetoshow=$langs->trans("AtEndOfMonth"); $align="center"; }
if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); } if ($fieldlist[$field]=='decalage') { $valuetoshow=$langs->trans("Offset"); }
if ($fieldlist[$field]=='width') { $valuetoshow=$langs->trans("Width"); } if ($fieldlist[$field]=='width' || $fieldlist[$field]=='nx') { $valuetoshow=$langs->trans("Width"); }
if ($fieldlist[$field]=='height') { $valuetoshow=$langs->trans("Height"); } if ($fieldlist[$field]=='height' || $fieldlist[$field]=='ny') { $valuetoshow=$langs->trans("Height"); }
if ($fieldlist[$field]=='unit') { $valuetoshow=$langs->trans("MeasuringUnit"); } if ($fieldlist[$field]=='unit' || $fieldlist[$field]=='metric') { $valuetoshow=$langs->trans("MeasuringUnit"); }
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); } if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; } if ($fieldlist[$field]=='accountancy_code_sell'){ $valuetoshow=$langs->trans("AccountancyCodeSell"); $sortable=0; }
@ -1229,6 +1241,20 @@ if ($id)
if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); } if ($fieldlist[$field]=='sens') { $valuetoshow=$langs->trans("Sens"); }
if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); } if ($fieldlist[$field]=='category_type') { $valuetoshow=$langs->trans("Calculated"); }
if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); } if ($fieldlist[$field]=='formula') { $valuetoshow=$langs->trans("Formula"); }
if ($fieldlist[$field]=='paper_size') { $valuetoshow=$langs->trans("PaperSize"); }
if ($fieldlist[$field]=='orientation') { $valuetoshow=$langs->trans("Orientation"); }
if ($fieldlist[$field]=='leftmargin') { $valuetoshow=$langs->trans("LeftMargin"); }
if ($fieldlist[$field]=='topmargin') { $valuetoshow=$langs->trans("TopMargin"); }
if ($fieldlist[$field]=='spacex') { $valuetoshow=$langs->trans("SpaceX"); }
if ($fieldlist[$field]=='spacey') { $valuetoshow=$langs->trans("SpaceY"); }
if ($fieldlist[$field]=='font_size') { $valuetoshow=$langs->trans("FontSize"); }
if ($fieldlist[$field]=='custom_x') { $valuetoshow=$langs->trans("CustomX"); }
if ($fieldlist[$field]=='custom_y') { $valuetoshow=$langs->trans("CustomY"); }
if ($fieldlist[$field]=='content') { $valuetoshow=$langs->trans("Content"); }
if ($fieldlist[$field]=='percent') { $valuetoshow=$langs->trans("Percentage"); }
if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("Info"); }
if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); }
if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); }
// Affiche nom du champ // Affiche nom du champ
if ($showfield) if ($showfield)

View File

@ -365,7 +365,6 @@ if ($mode != 'marketplace')
print '<br><br><br><br>'; print '<br><br><br><br>';
// Show list of modules // Show list of modules
print '<table summary="list_of_modules" id="list_of_modules" class="liste" width="100%">'."\n"; print '<table summary="list_of_modules" id="list_of_modules" class="liste" width="100%">'."\n";

View File

@ -344,7 +344,7 @@ class Categories extends DolibarrApi
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param Categorie $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
* *
* @todo use an array for properties to clean * @todo use an array for properties to clean

View File

@ -141,6 +141,12 @@ class Contrat extends CommonObject
*/ */
var $lines=array(); var $lines=array();
/**
* Maps ContratLigne IDs to $this->lines indexes
* @var int[]
*/
protected $lines_id_index_mapper=array();
/** /**
* Constructor * Constructor
@ -221,38 +227,7 @@ class Contrat extends CommonObject
*/ */
function active_line($user, $line_id, $date, $date_end='', $comment='') function active_line($user, $line_id, $date, $date_end='', $comment='')
{ {
global $langs,$conf; $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment);
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,";
$sql.= " date_ouverture = ".(dol_strlen($date)!=0?"'".$this->db->idate($date)."'":"null").",";
$sql.= " date_fin_validite = ".(dol_strlen($date_end)!=0?"'".$this->db->idate($date_end)."'":"null").",";
$sql.= " fk_user_ouverture = ".$user->id.",";
$sql.= " date_cloture = null,";
$sql.= " commentaire = '".$this->db->escape($comment)."'";
$sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3 OR statut = 5)";
dol_syslog(get_class($this)."::active_line", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
// Call trigger
$result=$this->call_trigger('CONTRACT_SERVICE_ACTIVATE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
} }
@ -267,37 +242,7 @@ class Contrat extends CommonObject
*/ */
function close_line($user, $line_id, $date_end, $comment='') function close_line($user, $line_id, $date_end, $comment='')
{ {
global $langs,$conf; $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment);
$error=0;
// statut actif : 4
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 5,";
$sql.= " date_cloture = '".$this->db->idate($date_end)."',";
$sql.= " fk_user_cloture = ".$user->id.",";
$sql.= " commentaire = '".$this->db->escape($comment)."'";
$sql.= " WHERE rowid = ".$line_id . " AND statut = 4";
$resql = $this->db->query($sql);
if ($resql)
{
// Call trigger
$result=$this->call_trigger('CONTRACT_SERVICE_CLOSE',$user);
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
// End call triggers
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
} }
@ -748,6 +693,7 @@ class Contrat extends CommonObject
$line->fetch_optionals($line->id,$extralabelsline); $line->fetch_optionals($line->id,$extralabelsline);
$this->lines[] = $line; $this->lines[] = $line;
$this->lines_id_index_mapper[$line->id] = key($this->lines);
//dol_syslog("1 ".$line->desc); //dol_syslog("1 ".$line->desc);
//dol_syslog("2 ".$line->product_desc); //dol_syslog("2 ".$line->product_desc);
@ -852,6 +798,7 @@ class Contrat extends CommonObject
$this->lines[] = $line; $this->lines[] = $line;
$this->lines_id_index_mapper[$line->id] = key($this->lines);
$total_ttc+=$objp->total_ttc; $total_ttc+=$objp->total_ttc;
$total_vat+=$objp->total_tva; $total_vat+=$objp->total_tva;
@ -2947,4 +2894,106 @@ class ContratLigne extends CommonObjectLine
return -1; return -1;
} }
} }
/**
* Activate a contract line
*
* @param User $user Objet User who activate contract
* @param int $date Date d'ouverture
* @param int|string $date_end Date fin prevue
* @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/
function active_line($user, $date, $date_end = '', $comment = '')
{
global $langs, $conf;
// Update object
$this->date_ouverture = $date;
$this->date_fin_validite = $date_end;
$this->fk_user_ouverture = $user->id;
$this->date_cloture = null;
$this->commentaire = $comment;
$error = 0;
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = 4,";
$sql .= " date_ouverture = " . (dol_strlen($date) != 0 ? "'" . $this->db->idate($date) . "'" : "null") . ",";
$sql .= " date_fin_validite = " . (dol_strlen($date_end) != 0 ? "'" . $this->db->idate($date_end) . "'" : "null") . ",";
$sql .= " fk_user_ouverture = " . $user->id . ",";
$sql .= " date_cloture = null,";
$sql .= " commentaire = '" . $this->db->escape($comment) . "'";
$sql .= " WHERE rowid = " . $this->id . " AND (statut = 0 OR statut = 3 OR statut = 5)";
dol_syslog(get_class($this) . "::active_line", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
// Call trigger
$result = $this->call_trigger('CONTRACT_SERVICE_ACTIVATE', $user);
if ($result < 0) {
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
}
/**
* Close a contract line
*
* @param User $user Objet User who close contract
* @param int $date_end Date end
* @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/
function close_line($user, $date_end, $comment = '')
{
global $langs, $conf;
// Update object
$this->date_cloture = $date_end;
$this->fk_user_cloture = $user->id;
$this->commentaire = $comment;
$error = 0;
// statut actif : 4
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "contratdet SET statut = 5,";
$sql .= " date_cloture = '" . $this->db->idate($date_end) . "',";
$sql .= " fk_user_cloture = " . $user->id . ",";
$sql .= " commentaire = '" . $this->db->escape($comment) . "'";
$sql .= " WHERE rowid = " . $this->id . " AND statut = 4";
$resql = $this->db->query($sql);
if ($resql) {
// Call trigger
$result = $this->call_trigger('CONTRACT_SERVICE_CLOSE', $user);
if ($result < 0) {
$error++;
$this->db->rollback();
return -1;
}
// End call triggers
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
}
}
} }

View File

@ -223,6 +223,16 @@ HelpCenterDesc1=This area can help you to get a Help support service on Dolibarr
HelpCenterDesc2=Some part of this service are available in <b>english only</b>. HelpCenterDesc2=Some part of this service are available in <b>english only</b>.
CurrentMenuHandler=Current menu handler CurrentMenuHandler=Current menu handler
MeasuringUnit=Measuring unit MeasuringUnit=Measuring unit
LeftMargin=Left margin
TopMargin=Top margin
PaperSize=Paper type
Orientation=Orientation
SpaceX=Space X
SpaceY=Space Y
FontSize=Font size
Content=Content
NoticePeriod=Notice
NewByMonth=New by month
Emails=E-mails Emails=E-mails
EMailsSetup=E-mails setup EMailsSetup=E-mails setup
EMailsDesc=This page allows you to overwrite your PHP parameters for e-mails sending. In most cases on Unix/Linux OS, your PHP setup is correct and these parameters are useless. EMailsDesc=This page allows you to overwrite your PHP parameters for e-mails sending. In most cases on Unix/Linux OS, your PHP setup is correct and these parameters are useless.
@ -815,6 +825,7 @@ DictionaryPaymentModes=Payment modes
DictionaryTypeContact=Contact/Address types DictionaryTypeContact=Contact/Address types
DictionaryEcotaxe=Ecotax (WEEE) DictionaryEcotaxe=Ecotax (WEEE)
DictionaryPaperFormat=Paper formats DictionaryPaperFormat=Paper formats
DictionaryFormatCards=Cards formats
DictionaryFees=Types of fees DictionaryFees=Types of fees
DictionarySendingMethods=Shipping methods DictionarySendingMethods=Shipping methods
DictionaryStaff=Staff DictionaryStaff=Staff

View File

@ -613,6 +613,9 @@ NoFileFound=No documents saved in this directory
CurrentUserLanguage=Current language CurrentUserLanguage=Current language
CurrentTheme=Current theme CurrentTheme=Current theme
CurrentMenuManager=Current menu manager CurrentMenuManager=Current menu manager
Browser=Browser
Layout=Layout
Screen=Screen
DisabledModules=Disabled modules DisabledModules=Disabled modules
For=For For=For
ForCustomer=For customer ForCustomer=For customer

View File

@ -925,6 +925,22 @@ class Product extends CommonObject
// End call triggers // End call triggers
} }
// Delete from product_batch on product delete
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch';
$sql.= " WHERE fk_product_stock IN (";
$sql.= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock';
$sql.= " WHERE fk_product = ".$id.")";
dol_syslog(get_class($this).'::delete', LOG_DEBUG);
$result = $this->db->query($sql);
if (! $result)
{
$error++;
$this->errors[] = $this->db->lasterror();
}
}
// Delete all child tables // Delete all child tables
if (! $error) if (! $error)
{ {

View File

@ -275,7 +275,7 @@ class StockMovements extends DolibarrApi
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param MouvementStock $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
* *
* @todo use an array for properties to clean * @todo use an array for properties to clean

View File

@ -244,7 +244,7 @@ class Warehouses extends DolibarrApi
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param Entrepot $object Object to clean
* @return array Array of cleaned object properties * @return array Array of cleaned object properties
* *
* @todo use an array for properties to clean * @todo use an array for properties to clean

View File

@ -780,7 +780,7 @@ class Task extends CommonObject
* @param User $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter. * @param User $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter.
* @param int $projectid Project id list separated with , to filter on project * @param int $projectid Project id list separated with , to filter on project
* @param int $taskid Task id to filter on a task * @param int $taskid Task id to filter on a task
* @param string $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined.
* @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') * @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task')
*/ */
function getUserRolesForProjectsOrTasks($userp, $usert, $projectid='', $taskid=0, $filteronprojstatus=-1) function getUserRolesForProjectsOrTasks($userp, $usert, $projectid='', $taskid=0, $filteronprojstatus=-1)