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

This commit is contained in:
Rui Strecht 2017-09-03 17:30:03 +01:00
commit 96521af778
19 changed files with 191 additions and 109 deletions

View File

@ -5,6 +5,11 @@ English Dolibarr ChangeLog
***** ChangeLog for 7.0.0 compared to 6.0.* *****
WARNING:
Following changes may create regression for some external modules, but were necessary to make Dolibarr better:
* The methode "cloture" on contact were renamed into "closeAll".
***** ChangeLog for 6.0.0 compared to 5.0.* *****

View File

@ -206,7 +206,7 @@ if ($id > 0 && empty($object->id))
{
// Load data of third party
$res=$object->fetch($id);
if ($object->id <= 0) dol_print_error($db,$object->error);
if ($object->id <= 0) dol_print_error($db,$object->error,$object->errors);
}
$title=$langs->trans("CustomerCard");
@ -608,7 +608,7 @@ if ($id > 0)
if(empty($reshook)){
$boxstat.= $hookmanager->resPrint;
}
$boxstat.='</td></tr>';
$boxstat.='</table>';
$boxstat.='</div>';

View File

@ -2235,7 +2235,6 @@ if ($action == 'create')
print ' / ' . price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
}
print ')';
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&fac_rec='.GETPOST('fac_rec','alpha')).'">'.$langs->trans("AddThirdParty").'</a>';
print '</td>';
}
else

View File

@ -316,7 +316,7 @@ class Facture extends CommonInvoice
$this->note_private=dol_concatdesc($this->note_private, $langs->trans("GeneratedFromRecurringInvoice", $_facrec->ref));
$this->array_options=$_facrec->array_options;
//if (! $this->remise) $this->remise = 0;
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
$this->brouillon = 1;
@ -636,7 +636,7 @@ class Facture extends CommonInvoice
if (empty($tva_tx)) $tva_npr=0;
$localtax1_tx=get_localtax($tva_tx,1,$soc,$mysoc,$tva_npr);
$localtax2_tx=get_localtax($tva_tx,2,$soc,$mysoc,$tva_npr);
$result_insert = $this->addline(
$_facrec->lines[$i]->desc,
$_facrec->lines[$i]->subprice,
@ -750,12 +750,12 @@ class Facture extends CommonInvoice
// Charge facture source
$facture=new Facture($this->db);
$this->fetch_optionals();
if(!empty($this->array_options)){
$facture->array_options = $this->array_options;
}
foreach($this->lines as &$line){
$line->fetch_optionals();//fetch extrafields
}

View File

@ -402,16 +402,16 @@ if (empty($reshook))
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
if ($ret < 0)
$error ++;
if (! $error) {
$result = $object->insertExtraFields();
if ($result < 0) {
$error ++;
}
} else if ($reshook < 0)
$error ++;
if ($error) {
$action = 'edit_extras';
setEventMessages($object->error, $object->errors, 'errors');
@ -760,7 +760,7 @@ if (empty($reshook))
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
$objectline = new FactureLigneRec($db);
if ($objectline->fetch(GETPOST('lineid')))
{
@ -771,7 +771,7 @@ if (empty($reshook))
setEventMessages($langs->trans('Error').$result, null, 'errors');
}
}
// Unset extrafield
if (is_array($extralabelsline))
{
@ -1054,7 +1054,7 @@ if ($action == 'create')
// Bank account
if ($object->fk_account > 0)
{
print "<tr><td>".$langs->trans('RIB')."</td><td>";
print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
print "</td></tr>";
}
@ -1361,11 +1361,11 @@ else
print "</td>";
print '</tr>';
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';

View File

@ -752,7 +752,13 @@ if (empty($reshook))
// Close all lines
else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer)
{
$object->cloture($user);
$object->closeAll($user);
}
// Close all lines
else if ($action == 'confirm_activate' && $confirm == 'yes' && $user->rights->contrat->creer)
{
$object->activateAll($user);
}
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
@ -1313,6 +1319,11 @@ else
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CloseAContract"),$langs->trans("ConfirmCloseContract"),"confirm_close",'',0,1);
}
if ($action == 'activate')
{
print $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("ActivateAllOnContract"),$langs->trans("ConfirmActivateAllOnContract"),"confirm_activate",'',0,1);
}
/*
@ -1617,7 +1628,7 @@ else
print $langs->trans("DateStartPlanned").': ';
if ($objp->date_debut)
{
print dol_print_date($db->jdate($objp->date_debut));
print dol_print_date($db->jdate($objp->date_debut), 'day');
// Warning si date prevu passee et pas en service
if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) {
$warning_delay=$conf->contrat->services->inactifs->warning_delay / 3600 / 24;
@ -1630,7 +1641,7 @@ else
print $langs->trans("DateEndPlanned").': ';
if ($objp->date_fin)
{
print dol_print_date($db->jdate($objp->date_fin));
print dol_print_date($db->jdate($objp->date_fin), 'day');
if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) {
$warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24;
$textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days");
@ -1849,21 +1860,21 @@ else
// Si pas encore active
if (! $objp->date_debut_reelle) {
print $langs->trans("DateStartReal").': ';
if ($objp->date_debut_reelle) print dol_print_date($objp->date_debut_reelle);
if ($objp->date_debut_reelle) print dol_print_date($objp->date_debut_reelle, 'day');
else print $langs->trans("ContractStatusNotRunning");
}
// Si active et en cours
if ($objp->date_debut_reelle && ! $objp->date_fin_reelle) {
print $langs->trans("DateStartReal").': ';
print dol_print_date($objp->date_debut_reelle);
print dol_print_date($objp->date_debut_reelle, 'day');
}
// Si desactive
if ($objp->date_debut_reelle && $objp->date_fin_reelle) {
print $langs->trans("DateStartReal").': ';
print dol_print_date($objp->date_debut_reelle);
print dol_print_date($objp->date_debut_reelle, 'day');
print ' &nbsp;-&nbsp; ';
print $langs->trans("DateEndReal").': ';
print dol_print_date($objp->date_fin_reelle);
print dol_print_date($objp->date_fin_reelle, 'day');
}
if (! empty($objp->comment)) print "<br>".$objp->comment;
print '</td>';
@ -2071,6 +2082,10 @@ else
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=' . $object->element . '">' . $langs->trans("ToClone") . '</a></div>';
}
if ($object->nbofservicesclosed > 0)
{
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=activate">'.$langs->trans("ActivateAllContracts").'</a></div>';
}
if ($object->nbofservicesclosed < $nbofservices)
{
//if (! $numactive)
@ -2121,9 +2136,9 @@ else
print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
// Show links to link elements
$linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -247,13 +247,63 @@ class Contrat extends CommonObject
}
/**
* Open all lines of a contract
*
* @param User $user Object User making action
* @param int|string $date_start Date start (now if empty)
* @return int <0 if KO, >0 if OK
*/
function activateAll($user, $date_start='')
{
if (empty($date_start)) $date_start = dol_now();
$this->db->begin();
// Load lines
$this->fetch_lines();
$ok=true;
foreach($this->lines as $contratline)
{
// Open lines not already open
if ($contratline->statut != 4)
{
$result = $contratline->active_line($user, $date_start, -1);
if ($result < 0)
{
$ok=false;
break;
}
}
}
if ($this->statut == 0)
{
$result=$this->validate($user);
if ($result < 0) $ok=false;
}
if ($ok)
{
$this->db->commit();
return 1;
}
else
{
dol_print_error($this->db,'Error in activateAll function');
$this->db->rollback();
return -1;
}
}
/**
* Close all lines of a contract
*
* @param User $user Object User making action
* @return void
* @param User $user Object User making action
* @return int <0 if KO, >0 if OK
*/
function cloture($user)
function closeAll($user)
{
$this->db->begin();
@ -263,7 +313,7 @@ class Contrat extends CommonObject
$ok=true;
foreach($this->lines as $contratline)
{
// Close line not already closed
// Close lines not already closed
if ($contratline->statut != 5)
{
$contratline->date_cloture=dol_now();
@ -287,11 +337,13 @@ class Contrat extends CommonObject
if ($ok)
{
$this->db->commit();
return 1;
}
else
{
dol_print_error($this->db,'Error in cloture function');
dol_print_error($this->db,'Error in closeAll function');
$this->db->rollback();
return -1;
}
}
@ -920,8 +972,8 @@ class Contrat extends CommonObject
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
if ($result < 0)
$result=$this->insertExtraFields();
if ($result < 0)
{
$error++;
}
@ -1278,7 +1330,7 @@ class Contrat extends CommonObject
//// End call triggers
}
}
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
@ -1361,7 +1413,8 @@ class Contrat extends CommonObject
if (empty($info_bits)) $info_bits=0;
if (empty($pu_ht) || ! is_numeric($pu_ht)) $pu_ht=0;
if (empty($pu_ttc)) $pu_ttc=0;
if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0;
if (empty($txtva) || ! is_numeric($txtva)) $txtva=0;
if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0;
if (empty($txlocaltax2) || ! is_numeric($txlocaltax2)) $txlocaltax2=0;
if ($price_base_type=='HT')
@ -1464,6 +1517,8 @@ class Contrat extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
$contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element);
$result=$this->update_statut($user);
if ($result > 0)
{
@ -1472,7 +1527,7 @@ class Contrat extends CommonObject
{
$contractline = new ContratLigne($this->db);
$contractline->array_options=$array_options;
$contractline->id= $this->db->last_insert_id(MAIN_DB_PREFIX.$contractline->table_element);
$contractline->id=$contractlineid;
$result=$contractline->insertExtraFields();
if ($result < 0)
{
@ -1486,13 +1541,20 @@ class Contrat extends CommonObject
$result=$this->call_trigger('LINECONTRACT_INSERT',$user);
if ($result < 0)
{
$this->db->rollback();
return -1;
$error++;
}
// End call triggers
}
if ($error)
{
$this->db->rollback();
return -1;
}
else
{
$this->db->commit();
return 1;
return $contractlineid;
}
}
else
@ -2998,11 +3060,11 @@ class ContratLigne extends CommonObjectLine
/**
* 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
* @param User $user Objet User who activate contract
* @param int $date Date activation
* @param int|string $date_end Date planned end. Use '-1' to keep it unchanged.
* @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/
function active_line($user, $date, $date_end = '', $comment = '')
{
@ -3021,7 +3083,7 @@ class ContratLigne extends CommonObjectLine
$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") . ",";
if ($date_end >= 0) $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) . "'";

View File

@ -4349,7 +4349,7 @@ abstract class CommonObject
}
elseif ($value=='')
{
$this->array_options[$key] = null;
$new_array_options[$key] = null;
}
break;
/*case 'select': // Not required, we chosed value='0' for undefined values
@ -4359,13 +4359,13 @@ abstract class CommonObject
}
break;*/
case 'price':
$this->array_options[$key] = price2num($this->array_options[$key]);
$new_array_options[$key] = price2num($this->array_options[$key]);
break;
case 'date':
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
break;
case 'datetime':
$this->array_options[$key]=$this->db->idate($this->array_options[$key]);
$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
break;
case 'link':
$param_list=array_keys($attributeParam ['options']);
@ -4381,7 +4381,7 @@ abstract class CommonObject
if (is_numeric($value)) $res=$object->fetch($value);
else $res=$object->fetch('',$value);
if ($res > 0) $this->array_options[$key]=$object->id;
if ($res > 0) $new_array_options[$key]=$object->id;
else
{
$this->error="Ref '".$value."' for object '".$object->element."' not found";
@ -4421,9 +4421,9 @@ abstract class CommonObject
// Add field o fattribut
if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate)
{
if ($this->array_options[$key] != '')
if ($new_array_options[$key] != '')
{
$sql.=",'".$this->db->escape($this->array_options[$key])."'";
$sql.=",'".$this->db->escape($new_array_options[$key])."'";
}
else
{

View File

@ -660,7 +660,7 @@ class ExtraFields
$sql.= " '".$param."',";
$sql.= " ".$list.", ";
$sql.= " ".$ishidden.", ";
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
$sql .= " " . $user->id . ",";
$sql .= " " . $user->id . ",";
@ -1128,13 +1128,13 @@ class ExtraFields
$form = new Form($db);
$value_arr=explode(',',$value);
$out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $param['options'], $value_arr, '', 0, '', 0, '100%');
$out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
}
elseif ($type == 'radio')
{
$out='';
foreach ($param['options'] as $keyopt=>$val )
foreach ($param['options'] as $keyopt => $val)
{
$out.='<input class="flat '.$showsize.'" type="radio" name="'.$keysuffix.'options_'.$key.$keyprefix.'" '.($moreparam?$moreparam:'');
$out.=' value="'.$keyopt.'"';

View File

@ -776,7 +776,7 @@ class DoliDBMysqli extends DoliDB
{
$sql = "ALTER TABLE ".$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') {
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') {
$sql.="(".$field_desc['value'].")";
}
if ($field_desc['null'] == 'not null' || $field_desc['null'] == 'NOT NULL')
@ -796,9 +796,9 @@ class DoliDBMysqli extends DoliDB
$sql.=" NOT NULL";
}
if ($field_desc['default'])
if ($field_desc['default'] != '')
{
if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
}

View File

@ -1084,7 +1084,7 @@ class DoliDBPgsql extends DoliDB
{
$sql = "ALTER TABLE ".$table;
$sql .= " MODIFY COLUMN ".$field_name." ".$field_desc['type'];
if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') {
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int' || $field_desc['type'] == 'varchar') {
$sql.="(".$field_desc['value'].")";
}
@ -1103,9 +1103,9 @@ class DoliDBPgsql extends DoliDB
}
}
if ($field_desc['default'])
if ($field_desc['default'] != '')
{
if ($field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
}

View File

@ -97,8 +97,8 @@ class modCron extends DolibarrModules
// Cronjobs
$this->cronjobs = array(
0=>array('label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>10, 'status'=>1, 'test'=>true),
1=>array('label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>20, 'status'=>0, 'test'=>in_array($db->type, array('mysql','mysqli'))),
0=>array('label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true),
1=>array('label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>in_array($db->type, array('mysql','mysqli'))),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
);

View File

@ -117,15 +117,9 @@ class modFacture extends DolibarrModules
// Cronjobs
$this->cronjobs = array(
0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24),
0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600*24, 'priority'=>50, 'status'=>1, 'test'=>true),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600)
);
// List of cron jobs entries to add
// Example:
// $this->cronjobs=array(
// 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600)
// );
// Permissions
$this->rights = array();

View File

@ -99,13 +99,6 @@ class modGravatar extends DolibarrModules
//$r++;
// Cronjobs
$this->cronjobs = array(); // List of cron jobs entries to add
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600)
// );
$r=0;
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;

View File

@ -3,7 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2016 Pierre-Henry Favre <phf@atm-consulting.fr>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@ -60,7 +60,7 @@ class modMultiCurrency extends DolibarrModules
$this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Module to enter elements with a foreign currency";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
@ -175,12 +175,6 @@ class modMultiCurrency extends DolibarrModules
// 2=>array('file'=>'myboxc.php@multicurrency','note'=>'')
//);
// Cronjobs
$this->cronjobs = array(); // List of cron jobs entries to add
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>3600, 'unitfrequency'=>3600)
// );
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
@ -266,12 +260,12 @@ class modMultiCurrency extends DolibarrModules
//$this->_load_tables('/multicurrency/sql/');
$res = $this->_init($sql, $options);
if ($res)
{
$this->createFirstCurrency();
}
return $res;
}
@ -293,22 +287,22 @@ class modMultiCurrency extends DolibarrModules
/**
* Function called when module is enabled
* Create the currency from general setting
*
*
* @return int 1 if OK, 0 if KO
*/
private function createFirstCurrency()
{
global $conf,$user,$langs;
if (!MultiCurrency::checkCodeAlreadyExists($conf->currency))
{
$langs->loadCacheCurrencies('');
$multicurrency = new MultiCurrency($this->db);
$multicurrency->code = $conf->currency;
$multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')';
$r = $multicurrency->create($user);
if ($r > 0) $multicurrency->addRate(1);
}
}

View File

@ -31,9 +31,11 @@ NewContract=New contract
NewContractSubscription=New contract/subscription
AddContract=Create contract
DeleteAContract=Delete a contract
ActivateAllOnContract=Activate all services
CloseAContract=Close a contract
ConfirmDeleteAContract=Are you sure you want to delete this contract and all its services?
ConfirmValidateContract=Are you sure you want to validate this contract under name <b>%s</b>?
ConfirmActivateAllOnContract=This will open all services (not yet active). Are you sure you want to open all services?
ConfirmCloseContract=This will close all services (active or not). Are you sure you want to close this contract?
ConfirmCloseService=Are you sure you want to close this service with date <b>%s</b>?
ValidateAContract=Validate a contract
@ -67,6 +69,7 @@ BoardRunningServices=Expired running services
ServiceStatus=Status of service
DraftContracts=Drafts contracts
CloseRefusedBecauseOneServiceActive=Contract can't be closed as ther is at least one open service on it
ActivateAllContracts=Activate all contract lines
CloseAllContracts=Close all contract lines
DeleteContractLine=Delete a contract line
ConfirmDeleteContractLine=Are you sure you want to delete this contract line?

View File

@ -95,6 +95,7 @@ $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'ro
/*
* Actions
*/
@ -310,19 +311,19 @@ if (empty($reshook))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors');
$error++;
$action='create';
$action=($action=='add'?'create':'edit');
}
if (GETPOST('client') < 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors');
$error++;
$action='create';
$action=($action=='add'?'create':'edit');
}
if (GETPOST('fournisseur') < 0)
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors');
$error++;
$action='create';
$action=($action=='add'?'create':'edit');
}
if ($action == 'update')
@ -653,7 +654,7 @@ if (empty($reshook))
}
}
else
{
{
switch($_FILES['photo']['error'])
{
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
@ -683,7 +684,7 @@ if (empty($reshook))
if (! $error && ! count($errors))
{
if (! empty($backtopage))
if (! empty($backtopage))
{
header("Location: ".$backtopage);
exit;
@ -703,7 +704,7 @@ if (empty($reshook))
}
else
{
$action='create';
$action = ($action=='add'?'create':'edit');
}
}
@ -756,7 +757,6 @@ if (empty($reshook))
}
/*
* View
*/
@ -1356,11 +1356,12 @@ else
* Edition
*/
//print load_fiche_titre($langs->trans("EditCompany"));
if ($socid)
{
$res=$object->fetch_optionals($object->id,$extralabels);
$res=$object->fetch_optionals($object->id,$extralabels);
//if ($res < 0) { dol_print_error($db); exit; }
$head = societe_prepare_head($object);
@ -1466,8 +1467,6 @@ else
}
}
dol_htmloutput_errors($error,$errors);
if($object->localtax1_assuj==0){
$sub=0;
}else{$sub=1;}
@ -1475,7 +1474,6 @@ else
$sub2=0;
}else{$sub2=1;}
print "\n".'<script type="text/javascript">';
print '$(document).ready(function () {
var val='.$sub.';
@ -1942,7 +1940,7 @@ else
}
else
{
/*
/*
* View
*/

View File

@ -393,7 +393,8 @@ class Societe extends CommonObject
/**
* Create third party in database
* Create third party in database.
* $this->code_client = -1 and $this->code_fournisseur = -1 means automatic assignement.
*
* @param User $user Object of user that ask creation
* @return int >= 0 if OK, < 0 if KO
@ -672,7 +673,7 @@ class Societe extends CommonObject
if ($this->id_prof_exists($keymin, $vallabel, ($this->id > 0 ? $this->id : 0)))
{
$langs->load("errors");
$error++; $this->errors[] = $langs->transcountry('ProfId'.$i, $this->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
$error++; $this->errors[] = $langs->trans('Email')." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel).' ('.$langs->trans("ForbiddenBySetupRules").')';
}
}

View File

@ -74,6 +74,7 @@ $search_idprof3=trim(GETPOST('search_idprof3'));
$search_idprof4=trim(GETPOST('search_idprof4'));
$search_idprof5=trim(GETPOST('search_idprof5'));
$search_idprof6=trim(GETPOST('search_idprof6'));
$search_vat=trim(GETPOST('search_vat'));
$search_sale=trim(GETPOST("search_sale",'int'));
$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
$search_categ_sup=trim(GETPOST("search_categ_sup",'int'));
@ -182,8 +183,9 @@ $arrayfields=array(
's.idprof4'=>array('label'=>"ProfId4Short", 'checked'=>$checkedprofid4),
's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5),
's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6),
'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1),
's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel),
's.tva_intra'=>array('label'=>"VATIntra", 'checked'=>0),
'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1),
's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel),
's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm),
's.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
's.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
@ -245,6 +247,7 @@ if (empty($reshook))
$search_idprof4='';
$search_idprof5='';
$search_idprof6='';
$search_vat='';
$search_type='';
$search_type_thirdparty='';
$search_status=-1;
@ -386,7 +389,7 @@ else dol_print_error($db);
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, ";
$sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,";
$sql.= " s.email, s.phone, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.fk_pays,";
$sql.= " s.email, s.phone, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,";
$sql.= " s.tms as date_update, s.datec as date_creation,";
$sql.= " s.code_compta,s.code_compta_fournisseur,";
$sql.= " typent.code as typent_code,";
@ -452,6 +455,7 @@ if (strlen($search_idprof3)) $sql.= natural_search("s.ape",$search_idprof3);
if (strlen($search_idprof4)) $sql.= natural_search("s.idprof4",$search_idprof4);
if (strlen($search_idprof5)) $sql.= natural_search("s.idprof5",$search_idprof5);
if (strlen($search_idprof6)) $sql.= natural_search("s.idprof6",$search_idprof6);
if (strlen($search_vat)) $sql.= natural_search("s.tva_intra",$search_vat);
// Filter on type of thirdparty
if ($search_type > 0 && in_array($search_type,array('1,3','2,3'))) $sql .= " AND s.client IN (".$db->escape($search_type).")";
if ($search_type > 0 && in_array($search_type,array('4'))) $sql .= " AND s.fournisseur = 1";
@ -543,6 +547,7 @@ if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3
if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4);
if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5);
if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6);
if ($search_vat != '') $param.= '&search_vat='.urlencode($search_vat);
if ($search_country != '') $param.='&search_country='.urlencode($search_country);
if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
@ -813,11 +818,18 @@ if (! empty($arrayfields['s.idprof5']['checked']))
}
if (! empty($arrayfields['s.idprof6']['checked']))
{
// IdProf6
// IdProf6
print '<td class="liste_titre">';
print '<input class="flat searchstring" size="4" type="text" name="search_idprof6" value="'.dol_escape_htmltag($search_idprof6).'">';
print '</td>';
}
if (! empty($arrayfields['s.tva_intra']['checked']))
{
// Vat number
print '<td class="liste_titre">';
print '<input class="flat searchstring" size="4" type="text" name="search_vat" value="'.dol_escape_htmltag($search_vat).'">';
print '</td>';
}
// Type (customer/prospect/supplier)
if (! empty($arrayfields['customerorsupplier']['checked']))
@ -950,7 +962,7 @@ if (! empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_f
if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'],$_SERVER["PHP_SELF"],"s.town","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'],$_SERVER["PHP_SELF"],"s.zip","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.email']['checked'])) print_liste_field_titre($arrayfields['s.email']['label'],$_SERVER["PHP_SELF"],"s.email","",$param,'',$sortfield,$sortorder);
@ -962,6 +974,7 @@ if (! empty($arrayfields['s.ape']['checked'])) print_liste_field_titr
if (! empty($arrayfields['s.idprof4']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$param,'class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.idprof5']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId5Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof5","",$param,'class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.idprof6']['checked'])) print_liste_field_titre($form->textwithpicto($langs->trans("ProfId6Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof6","",$param,'class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['s.tva_intra']['checked'])) print_liste_field_titre($arrayfields['s.tva_intra']['label'],$_SERVER["PHP_SELF"],"s.tva_intra","",$param,'class="nowrap"',$sortfield,$sortorder);
if (! empty($arrayfields['customerorsupplier']['checked'])) print_liste_field_titre(''); // type of customer
if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) print_liste_field_titre($arrayfields['s.fk_prospectlevel']['label'],$_SERVER["PHP_SELF"],"s.fk_prospectlevel","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titre($arrayfields['s.fk_stcomm']['label'],$_SERVER["PHP_SELF"],"s.fk_stcomm","",$param,'align="center"',$sortfield,$sortorder);
@ -1151,6 +1164,11 @@ while ($i < min($num, $limit))
print "<td>".$obj->idprof6."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.tva_intra']['checked']))
{
print "<td>".$obj->tva_intra."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Type
if (! empty($arrayfields['customerorsupplier']['checked']))
{