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

This commit is contained in:
Maxime Kohlhaas 2013-07-31 15:23:27 +02:00
commit 3395df2b66
24 changed files with 275 additions and 155 deletions

View File

@ -144,37 +144,6 @@ For users:
- Fix: [ bug #972 ] Auto completion contact field do not take account the min caract number before search - Fix: [ bug #972 ] Auto completion contact field do not take account the min caract number before search
- Fix : [ bug #971 ] html.form.class.php select_contact with autocomplete do not exclude id from exclude array - Fix : [ bug #971 ] html.form.class.php select_contact with autocomplete do not exclude id from exclude array
For translators:
- Update language files.
For developers:
- System of menu managers has been rewritten to reduce code to do same things.
- An external module can force its theme.
- Add function dol_set_focus('#xxx').
- A mymodule can bring its own core/modules/mymodule/modules_mymodule.php file.
- Removed some not used libraries.
- More web services.
- Renamed some database fields, code variables and parameters from french to english.
- First change to manage margins on contracts.
- Add hook getFormMail.
- Function plimit of databases drivers accept -1 as value (it means default value set
into conf->liste_limit).
- New: Add option dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen,
dol_no_mouse_hover and dol_use_jmobile onto login page (to support different terminal).
- New: dol_syslog method accept a suffix to use different log files for log.
- New: Type of fields are received by export format handlers.
- New: when adding an action, we can define a free code to tag it for a specific need.
- New: Enhance Dolibarr migration process to include migration script of external
modules.
- New: [ task #811 ] Uniformanize note field.
WARNING: If you used external modules, some of them may need to be upgraded due to:
- Fields of classes were renamed to be normalized (nom, prenom, cp, ville, adresse, tel
were renamed into lastname, firstname, zip, town, address, phone).
This may also be true for some fields into web services.
- If module use hook pdf_writelinedesc, module may have to add return 1 at end of
function to keep same behaviour.
***** ChangeLog for 3.3.4 compared to 3.3.3 ***** ***** ChangeLog for 3.3.4 compared to 3.3.3 *****

View File

@ -4,13 +4,16 @@
# #
# Laurent Destailleur - eldy@users.sourceforge.net # Laurent Destailleur - eldy@users.sourceforge.net
#------------------------------------------------------ #------------------------------------------------------
# Usage: txpush.sh [all|xx_XX] # Usage: txpush.sh (source|all|xx_XX) [-r dolibarr.file] [-f]
#------------------------------------------------------ #------------------------------------------------------
# Syntax # Syntax
if [ "x$1" = "x" ] if [ "x$1" = "x" ]
then then
echo "Usage: txpush.sh (source|all|xx_XX) [-r dolibarr.file]" echo "This push local files to transifex."
echo "Note: If you push a langauge file (not source), file will be skipped if transifex file is newer."
echo " Using -f will overwrite translation but not memory."
echo "Usage: txpush.sh (source|all|xx_XX) [-r dolibarr.file] [-f]"
exit exit
fi fi
@ -28,7 +31,7 @@ then
echo "tx push -s $2 $3" echo "tx push -s $2 $3"
tx push -s $2 $3 tx push -s $2 $3
else else
echo "tx push -t -l $1 $2 $3" echo "tx push -t -l $1 $2 $3 $4"
tx push -t -l $1 $2 $3 tx push -t -l $1 $2 $3 $4
fi fi
fi fi

View File

@ -64,7 +64,7 @@ if ($action == 'updateMask')
if (isset($res)) if (isset($res))
{ {
if ($res < 0) if ($res > 0)
setEventMessage($langs->trans("SetupSaved")); setEventMessage($langs->trans("SetupSaved"));
else else
setEventMessage($langs->trans("Error"), 'errors'); setEventMessage($langs->trans("Error"), 'errors');
@ -536,4 +536,4 @@ print '</table>';
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>

View File

@ -916,20 +916,14 @@ else
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$result=$object->fetch($id,$ref); $result=$object->fetch($id,$ref);
if ($result > 0) if ($result < 0) dol_print_error($db,$object->error);
{ $result=$object->fetch_lines();
$result=$object->fetch_lines(); if ($result < 0) dol_print_error($db,$object->error);
} $result=$object->fetch_thirdparty();
if ($result < 0) if ($result < 0) dol_print_error($db,$object->error);
{
dol_print_error($db,$object->error);
exit;
}
dol_htmloutput_errors($mesg,''); dol_htmloutput_errors($mesg,'');
$object->fetch_thirdparty();
$nbofservices=count($object->lines); $nbofservices=count($object->lines);
$author = new User($db); $author = new User($db);
@ -1092,18 +1086,26 @@ else
$productstatic=new Product($db); $productstatic=new Product($db);
// Title line for service // Title line for service
print '<table class="notopnoleft allwidth">'; // Array with (n*2)+1 lines //print '<table class="notopnoleft allwidth">'; // Array with (n*2)+1 lines
$cursorline=1; $cursorline=1;
while ($cursorline <= $nbofservices) while ($cursorline <= $nbofservices)
{ {
print '<tr height="16" '.$bc[false].'>'; //print '<tr '.$bc[false].'>';
print '<td class="liste_titre" width="90" style="border-left: 1px solid #'.$colorb.'; border-top: 1px solid #'.$colorb.'; border-bottom: 1px solid #'.$colorb.';">'; //print '<td width="90" style="border-left: 1px solid #'.$colorb.'; border-top: 1px solid #'.$colorb.'; border-bottom: 1px solid #'.$colorb.';">';
print $langs->trans("ServiceNb",$cursorline).'</td>'; //print $langs->trans("ServiceNb",$cursorline).'</td>';
print '<td class="tab" style="border-right: 1px solid #'.$colorb.'; border-top: 1px solid #'.$colorb.'; border-bottom: 1px solid #'.$colorb.';" rowspan="2">'; // print '<td class="tab" style="border-right: 1px solid #'.$colorb.'; border-top: 1px solid #'.$colorb.'; border-bottom: 1px solid #'.$colorb.';" rowspan="2">';
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="elrowid" value="'.GETPOST('rowid').'">';
print '<input type="hidden" name="idprod" value="'.($objp->fk_product?$objp->fk_product:'0').'">';
print '<input type="hidden" name="fournprice" value="'.($objp->fk_fournprice?$objp->fk_fournprice:'0').'">';
// Area with common detail of line // Area with common detail of line
print '<table class="notopnoleft" width="100%">'; print '<table class="notopnoleft allwidth" width="100%">';
$sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.description, cd.price_ht, cd.qty,"; $sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.description, cd.price_ht, cd.qty,";
$sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,"; $sql.= " cd.tva_tx, cd.remise_percent, cd.info_bits, cd.subprice,";
@ -1121,7 +1123,7 @@ else
$total = 0; $total = 0;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Service").'</td>'; print '<td>'.$langs->trans("ServiceNb",$cursorline).'</td>';
print '<td width="50" align="center">'.$langs->trans("VAT").'</td>'; print '<td width="50" align="center">'.$langs->trans("VAT").'</td>';
print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>'; print '<td width="50" align="right">'.$langs->trans("PriceUHT").'</td>';
print '<td width="30" align="center">'.$langs->trans("Qty").'</td>'; print '<td width="30" align="center">'.$langs->trans("Qty").'</td>';
@ -1236,13 +1238,7 @@ else
} }
// Ligne en mode update // Ligne en mode update
else else
{ {
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="updateligne">';
print '<input type="hidden" name="elrowid" value="'.GETPOST('rowid').'">';
print '<input type="hidden" name="idprod" value="'.($objp->fk_product?$objp->fk_product:'0').'">';
print '<input type="hidden" name="fournprice" value="'.($objp->fk_fournprice?$objp->fk_fournprice:'0').'">';
// Ligne carac // Ligne carac
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print '<td>'; print '<td>';
@ -1293,14 +1289,12 @@ else
$form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update"); $form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update");
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print "</form>\n";
} }
$db->free($result); $db->free($result);
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
@ -1312,6 +1306,7 @@ else
} }
print "</table>"; print "</table>";
print "</form>\n";
/* /*
@ -1521,13 +1516,14 @@ else
print '</form>'; print '</form>';
} }
print '</td>'; // End td if line is 1 /* print '</td>'; // End td if line is 1
print '</tr>'; print '</tr>';
print '<tr><td style="border-right: 1px solid #'.$colorb.'">&nbsp;</td></tr>'; print '<tr><td style="border-right: 1px solid #'.$colorb.'">&nbsp;</td></tr>';*/
$cursorline++; $cursorline++;
} }
print '</table>'; //print '</table>';
// Form to add new line // Form to add new line
if ($user->rights->contrat->creer && ($object->statut >= 0)) if ($user->rights->contrat->creer && ($object->statut >= 0))

View File

@ -80,7 +80,7 @@ $sql.= " AND c.entity = ".$conf->entity;
if ($socid) $sql.= " AND s.rowid = ".$socid; if ($socid) $sql.= " AND s.rowid = ".$socid;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'"; if ($search_nom) $sql.= " AND s.nom LIKE '%".$db->escape($search_nom)."%'";
if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'"; if ($search_contract) $sql.= " AND (".(is_numeric($search_contract)?"c.rowid = ".$db->escape($search_contract)." OR ":'')." c.ref LIKE '%".$db->escape($search_contract)."%')";
if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR cd.label LIKE '%".$db->escape($sall)."%' OR cd.description LIKE '%".$db->escape($sall)."%')"; if ($sall) $sql.= " AND (s.nom LIKE '%".$db->escape($sall)."%' OR cd.label LIKE '%".$db->escape($sall)."%' OR cd.description LIKE '%".$db->escape($sall)."%')";
$sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,"; $sql.= " GROUP BY c.rowid, c.ref, c.datec, c.date_contrat, c.statut,";
$sql.= " s.nom, s.rowid"; $sql.= " s.nom, s.rowid";

View File

@ -1400,7 +1400,7 @@ class Form
$objp->remise = $objp2->remise; $objp->remise = $objp2->remise;
$objp->price_by_qty_rowid = $objp2->rowid; $objp->price_by_qty_rowid = $objp2->rowid;
$this->_construct_product_list_option($objp, $opt, $optJson, 0, $selected); $this->constructProductListOption($objp, $opt, $optJson, 0, $selected);
$j++; $j++;
@ -1414,7 +1414,7 @@ class Form
} }
else else
{ {
$this->_construct_product_list_option($objp, $opt, $optJson, $price_level, $selected); $this->constructProductListOption($objp, $opt, $optJson, $price_level, $selected);
// Add new entry // Add new entry
// "key" value of json key array is used by jQuery automatically as selected value // "key" value of json key array is used by jQuery automatically as selected value
// "label" value of json key array is used by jQuery automatically as text for combo box // "label" value of json key array is used by jQuery automatically as text for combo box

View File

@ -538,7 +538,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/ */
function _tableau_info(&$pdf, $object, $posy, $outputlangs) function _tableau_info(&$pdf, $object, $posy, $outputlangs)
{ {
global $conf; global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('','', $default_font_size); $pdf->SetFont('','', $default_font_size);

View File

@ -321,17 +321,37 @@ class modSociete extends DolibarrModules
unset($this->export_entities_array[$r]['s.code_fournisseur']); unset($this->export_entities_array[$r]['s.code_fournisseur']);
} }
// Add extra fields // Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'"; $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname='extra.'.$obj->name;
$fieldlabel=ucfirst($obj->label); $fieldlabel=ucfirst($obj->label);
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $typeFilter="Text";
$this->export_entities_array[$r][$fieldname]='contact'; switch($obj->type)
} {
case 'int':
case 'double':
case 'price':
$typeFilter="Numeric";
break;
case 'date':
case 'datetime':
$typeFilter="Date";
break;
case 'boolean':
$typeFilter="Boolean";
break;
case 'sellist':
$typeFilter="List:".$obj->param;
break;
}
$this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
$this->export_entities_array[$r][$fieldname]='contact';
}
} }
// End add axtra fields // End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
@ -355,7 +375,7 @@ class modSociete extends DolibarrModules
$this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order) $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation"); $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation");
// Add extra fields // Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company' AND entity = ".$conf->entity; $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity = ".$conf->entity;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {
@ -390,7 +410,7 @@ class modSociete extends DolibarrModules
$this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order) $this->import_tables_array[$r]=array('s'=>MAIN_DB_PREFIX.'socpeople','extra'=>MAIN_DB_PREFIX.'socpeople_extrafields'); // List of tables to insert into (insert done in same order)
$this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.civilite'=>'UserTitle','s.lastname'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",'s.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation"); $this->import_fields_array[$r]=array('s.fk_soc'=>'ThirdPartyName*','s.civilite'=>'UserTitle','s.lastname'=>"Name*",'s.firstname'=>"Firstname",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_pays'=>"CountryCode",'s.birthday'=>"BirthdayDate",'s.poste'=>"Role",'s.phone'=>"Phone",'s.phone_perso'=>"PhonePerso",'s.phone_mobile'=>"PhoneMobile",'s.fax'=>"Fax",'s.email'=>"Email",'s.note_private'=>"Note",'s.note_public'=>"Note",'s.datec'=>"DateCreation");
// Add extra fields // Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact' AND entity = ".$conf->entity; $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople' AND entity = ".$conf->entity;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example) if ($resql) // This can fail when class is used on old database (during migration for example)
{ {

View File

@ -56,7 +56,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n"; $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="updateMaskInvoice">'; $texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">'; $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">'; $texte.= '<table class="nobordernopadding" width="100%">';

View File

@ -59,6 +59,7 @@ class Expedition extends CommonObject
var $billed; var $billed;
var $note_public; var $note_public;
var $note_private; var $note_private;
var $model_pdf;
var $trueWeight; var $trueWeight;
var $weight_units; var $weight_units;
@ -162,6 +163,8 @@ class Expedition extends CommonObject
global $conf, $langs; global $conf, $langs;
$now=dol_now(); $now=dol_now();
if (empty($this->model_pdf)) $this->model_pdf=$conf->global->EXPEDITION_ADDON_PDF;
require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT .'/product/stock/class/mouvementstock.class.php';
$error = 0; $error = 0;
@ -196,6 +199,7 @@ class Expedition extends CommonObject
$sql.= ", size_units"; $sql.= ", size_units";
$sql.= ", note_private"; $sql.= ", note_private";
$sql.= ", note_public"; $sql.= ", note_public";
$sql.= ", model_pdf";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
@ -217,6 +221,7 @@ class Expedition extends CommonObject
$sql.= ", ".$this->size_units; $sql.= ", ".$this->size_units;
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
$sql.= ")"; $sql.= ")";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);

View File

@ -984,7 +984,6 @@ ConditionIsCurrently=Condition is currently %s
TestNotPossibleWithCurrentBrowsers=Automatic detection not possible TestNotPossibleWithCurrentBrowsers=Automatic detection not possible
YouUseBestDriver=You use driver %s that is best driver available currently. YouUseBestDriver=You use driver %s that is best driver available currently.
YouDoNotUseBestDriver=You use drive %s but driver %s is recommanded. YouDoNotUseBestDriver=You use drive %s but driver %s is recommanded.
SearchProduct=Optimisation recherche produits
NbOfProductIsLowerThanNoPb=You have only %s products/services into database. This does not required any particular optimization. NbOfProductIsLowerThanNoPb=You have only %s products/services into database. This does not required any particular optimization.
SearchOptim=Search optimization SearchOptim=Search optimization
YouHaveXProductUseSearchOptim=You have %s product into database. You should add the constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 into Home-Setup-Other, you limit the search to the beginning of strings making possible for database to use index and you should get an immediate response. YouHaveXProductUseSearchOptim=You have %s product into database. You should add the constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 into Home-Setup-Other, you limit the search to the beginning of strings making possible for database to use index and you should get an immediate response.

View File

@ -87,8 +87,9 @@ ExpiredSince=Expiration date
RelatedContracts=Related contracts RelatedContracts=Related contracts
NoExpiredServices=No expired active services NoExpiredServices=No expired active services
ListOfServicesToExpireWithDuration=List of Services to expire in %s days ListOfServicesToExpireWithDuration=List of Services to expire in %s days
ListOfServicesToExpireWithDurationNeg=List of Services expired from more than %s days
ListOfServicesToExpire=List of Services to expire ListOfServicesToExpire=List of Services to expire
Service=Service NoteListOfYourExpiredServices=This list contains only services of contracts for third parties you are linked to as a sale representative.
##### Types de contacts ##### ##### Types de contacts #####
TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract TypeContact_contrat_internal_SALESREPSIGN=Sales representative signing contract

View File

@ -11,7 +11,7 @@ VersionUnknown=Inconnue
VersionRecommanded=Recommandé VersionRecommanded=Recommandé
SessionId=ID Session SessionId=ID Session
SessionSaveHandler=Modalité de sauvegarde des sessions SessionSaveHandler=Modalité de sauvegarde des sessions
SessionSavePath=Emplacement sauvegarde sessions SessionSavePath=Emplacement de sauvegarde sessions
PurgeSessions=Purge des sessions PurgeSessions=Purge des sessions
# ConfirmPurgeSessions=Do you really want to purge all sessions ? This will disconnect every user (except yourself). # ConfirmPurgeSessions=Do you really want to purge all sessions ? This will disconnect every user (except yourself).
NoSessionListWithThisHandler=Le gestionnaire de session configuré pour votre PHP ne permet pas de lister les sessions en cours NoSessionListWithThisHandler=Le gestionnaire de session configuré pour votre PHP ne permet pas de lister les sessions en cours

View File

@ -86,9 +86,10 @@ PaymentRenewContractId=Renouvellement service (numéro %s)
ExpiredSince=Expiré le ExpiredSince=Expiré le
RelatedContracts=Contrats associés RelatedContracts=Contrats associés
NoExpiredServices=Pas de services actifs expirés NoExpiredServices=Pas de services actifs expirés
ListOfServicesToExpireWithDuration=Liste des services actifs pour expirer à %s days ListOfServicesToExpireWithDuration=Liste des services actifs expirant dans %s jours
ListOfServicesToExpire=Liste des services actifs pour expirer ListOfServicesToExpireWithDurationNeg=Liste des services actifs expiré depuis plus de %s jours
Service=Service ListOfServicesToExpire=Liste des services actifs en expiration
NoteListOfYourExpiredServices=Cette list ne contient que les contrats de services des tiers pour lesquels vous êtes liés comme représentant commercial.
##### Types de contacts ##### ##### Types de contacts #####
TypeContact_contrat_internal_SALESREPSIGN=Commercial signataire du contrat TypeContact_contrat_internal_SALESREPSIGN=Commercial signataire du contrat

View File

@ -59,6 +59,7 @@ class Livraison extends CommonObject
var $date_delivery; // Date really received var $date_delivery; // Date really received
var $date_creation; var $date_creation;
var $date_valid; var $date_valid;
var $model_pdf;
/** /**
@ -89,6 +90,8 @@ class Livraison extends CommonObject
global $conf; global $conf;
dol_syslog("Livraison::create"); dol_syslog("Livraison::create");
if (empty($this->model_pdf)) $this->model_pdf=$conf->global->LIVRAISON_ADDON_PDF;
$error = 0; $error = 0;
@ -112,6 +115,7 @@ class Livraison extends CommonObject
$sql.= ", fk_address"; $sql.= ", fk_address";
$sql.= ", note_private"; $sql.= ", note_private";
$sql.= ", note_public"; $sql.= ", note_public";
$sql.= ", model_pdf";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= "'(PROV)'"; $sql.= "'(PROV)'";
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
@ -123,6 +127,7 @@ class Livraison extends CommonObject
$sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null"); $sql.= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : "null");
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
$sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); $sql.= ", ".(!empty($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null");
$sql.= ", ".(!empty($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null");
$sql.= ")"; $sql.= ")";
dol_syslog("Livraison::create sql=".$sql, LOG_DEBUG); dol_syslog("Livraison::create sql=".$sql, LOG_DEBUG);

View File

@ -85,7 +85,7 @@ if (! empty($tag) && ($unsuscrib=='1'))
$resql=$db->query($sql); $resql=$db->query($sql);
//Update status communication of contact prospect //Update status communication of contact prospect
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=-1 WHERE rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET no_email=1 WHERE rowid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)";
dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG); dol_syslog("public/emailing/mailing-unsubscribe.php : Mail unsubcribe contact : ".$sql, LOG_DEBUG);
$resql=$db->query($sql); $resql=$db->query($sql);

0
scripts/company/export-contacts-xls-example.php Normal file → Executable file
View File

0
scripts/company/sync_contacts_dolibarr2ldap.php Normal file → Executable file
View File

View File

@ -36,16 +36,18 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
exit(-1); exit(-1);
} }
if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm')) || ! in_array($argv[2],array('thirdparties','contacts')))
{ {
print "Usage: $script_file [test|confirm] [delay]\n"; print "Usage: $script_file (test|confirm) (thirdparties|contacts) [delay] [after]\n";
print "\n"; print "\n";
print "Send an email to customers to remind all all contracts services to expire.\n"; print "Send an email to customers to remind all contracts services to expire or expired.\n";
print "If you choose 'test' mode, no emails are sent.\n"; print "If you choose 'test' mode, no emails are sent.\n";
print "If you add a delay (nb of days), only services with expired date < today + delay are included.\n"; print "If you add param delay (nb of days), only services with expired date < today + delay are included.\n";
print "If you add param after (nb of days), only services with expired date >= today + delay are included.\n";
exit(-1); exit(-1);
} }
$mode=$argv[1]; $mode=$argv[1];
$targettype=$argv[2];
require($path."../../htdocs/master.inc.php"); require($path."../../htdocs/master.inc.php");
@ -69,33 +71,42 @@ print "***** ".$script_file." (".$version.") pid=".getmypid()." *****\n";
dol_syslog($script_file." launched with arg ".join(',',$argv)); dol_syslog($script_file." launched with arg ".join(',',$argv));
$now=dol_now('tzserver'); $now=dol_now('tzserver');
$duration_value=isset($argv[2])?$argv[2]:'none'; $duration_value=isset($argv[3])?$argv[3]:'none';
$duration_value2=isset($argv[4])?$argv[4]:'none';
print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n"; $error = 0;
print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value)?" delay=".$duration_value:"").(is_numeric($duration_value2)?" after=".$duration_value2:"")."\n";
if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1; if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1;
$sql = "SELECT DISTINCT s.nom as name, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, s.email, s.default_lang"; $sql = "SELECT c.ref, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel,";
$sql.= " s.rowid as sid, s.nom as name, s.email, s.default_lang";
if ($targettype == 'contacts') $sql.= ", sp.rowid as cid, sp.firstname as cfirstname, sp.lastname as clastname, sp.email as cemail";
$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s"; $sql .= " FROM ".MAIN_DB_PREFIX."societe AS s";
if ($targettype == 'contacts') $sql.= ", ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= ", ".MAIN_DB_PREFIX."contrat AS c"; $sql .= ", ".MAIN_DB_PREFIX."contrat AS c";
$sql .= ", ".MAIN_DB_PREFIX."contratdet AS cd"; $sql .= ", ".MAIN_DB_PREFIX."contratdet AS cd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product";
$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5"; $sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut < 5";
if (is_numeric($duration_value2)) $sql.= " AND cd.date_fin_validite >= '".$db->idate(dol_time_plus_duree($now, $duration_value2, "d"))."'";
if (is_numeric($duration_value)) $sql.= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
if ($targettype == 'contacts') $sql.= " AND s.rowid = sp.fk_soc";
$sql.= " ORDER BY";
if ($targettype == 'contacts') $sql.= " sp.email, sp.rowid,";
$sql.= " s.email ASC, s.rowid ASC, cd.date_fin_validite ASC"; // Order by email to allow one message per email
if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; //print $sql;
$sql .= " ORDER BY cd.date_fin_validite ASC, s.rowid ASC";
print $sql;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$oldemail = 'none'; $oldlang=''; $oldemail = 'none'; $oldsid = 0; $oldcid = 0; $oldlang='';
$total = 0; $foundtoprocess = 0; $total = 0; $foundtoprocess = 0;
print "We found ".$num." couples (services to expire - customer) qualified\n"; $trackthirdpartiessent = array();
dol_syslog("We found ".$num." couples (services to expire - customer) qualified");
print "We found ".$num." couples (services to expire-".$targettype.") qualified\n";
dol_syslog("We found ".$num." couples (services to expire-".$targettype.") qualified");
$message=''; $message='';
if ($num) if ($num)
@ -104,25 +115,40 @@ if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (($obj->email <> $oldemail) || $oldemail == 'none') $newemail=empty($obj->cemail)?$obj->email:$obj->cemail;
// Check if this record is a break after previous one
$startbreak=false;
if ($newemail <> $oldemail || $oldemail == 'none') $startbreak=true;
if ($obj->sid && $obj->sid <> $oldsid) $startbreak=true;
if ($obj->cid && $obj->cid <> $oldcid) $startbreak=true;
if ($startbreak)
{ {
// Break onto sales representative (new email or uid) // Break onto sales representative (new email or cid)
if (dol_strlen($oldemail) && $oldemail != 'none') if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail]))
{ {
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldcustomer,$duration_value); envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldtarget,$duration_value);
$trackthirdpartiessent[$oldsid.'|'.$oldemail]='contact id '.$oldcid;
} }
else else
{ {
if ($oldemail != 'none') print "- No email sent for ".$oldcustomer.", total: ".$total."\n"; if ($oldemail != 'none')
{
if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) print "- No email sent for '".$oldtarget."', total: ".$total."\n";
else print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n";
}
} }
$oldemail = $obj->email; $oldemail = $newemail;
$oldsid = $obj->sid;
$oldcid = $obj->cid;
$oldlang = $obj->lang; $oldlang = $obj->lang;
$oldcustomer=$obj->name; $oldtarget=(empty($obj->cfirstname) && empty($obj->clastname))?$obj->name:($obj->clastname." ".$obj->cfirstname);
$message = ''; $message = '';
$total = 0; $total = 0;
$foundtoprocess = 0; $foundtoprocess = 0;
$customer=$obj->name; $target=(empty($obj->cfirstname) && empty($obj->clastname))?$obj->name:($obj->clastname." ".$obj->cfirstname);
if (empty($obj->email)) print "Warning: Customer ".$customer." has no email. Notice disabled.\n"; //if (empty($newemail)) print "Warning: Customer ".$target." has no email. Notice disabled.\n";
} }
// Define line content // Define line content
@ -131,18 +157,21 @@ if ($resql)
$outputlangs->load("bills"); $outputlangs->load("bills");
$outputlangs->load("main"); $outputlangs->load("main");
$outputlangs->load("contracts"); $outputlangs->load("contracts");
$outputlangs->load("products");
if (dol_strlen($oldemail)) if (dol_strlen($newemail))
{ {
$message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)."), ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n"; $message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$outputlangs->trans("Service")." ".dol_concatdesc($obj->plabel,$obj->description)." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency)."), ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n";
dol_syslog("email_expire_services_to_customers.php: ".$obj->email); dol_syslog("email_expire_services_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++; $foundtoprocess++;
} }
print "Service to expire ".$obj->ref.", label ".$obj->label.", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day')." (linked to company ".$obj->nom.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): "; print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel,$obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", ":"")."email ".$newemail.", lang ".$outputlangs->defaultlang.": ";
if (dol_strlen($obj->email)) print "qualified."; if (dol_strlen($newemail)) print "qualified.";
else print "disqualified (no email)."; else print "disqualified (no email).";
print "\n"; print "\n";
unset($outputlangs);
$total += $obj->total_ttc; $total += $obj->total_ttc;
$i++; $i++;
@ -151,13 +180,18 @@ if ($resql)
// Si il reste des envois en buffer // Si il reste des envois en buffer
if ($foundtoprocess) if ($foundtoprocess)
{ {
if (dol_strlen($oldemail) && $oldemail != 'none') // Break onto email (new email) if (dol_strlen($oldemail) && $oldemail != 'none' && empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) // Break onto email (new email)
{ {
envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldcustomer,$duration_value); envoi_mail($mode,$oldemail,$message,$total,$oldlang,$oldtarget,$duration_value);
$trackthirdpartiessent[$oldsid.'|'.$oldemail]='contact id '.$oldcid;
} }
else else
{ {
if ($oldemail != 'none') print "- No email sent for ".$oldcustomer.", total: ".$total."\n"; if ($oldemail != 'none')
{
if (empty($trackthirdpartiessent[$oldsid.'|'.$oldemail])) print "- No email sent for '".$oldtarget."', total: ".$total."\n";
else print "- No email sent for '".$oldtarget."', total: ".$total." (already sent to ".$trackthirdpartiessent[$oldsid.'|'.$oldemail].")\n";
}
} }
} }
} }
@ -181,15 +215,15 @@ else
* Send email * Send email
* *
* @param string $mode Mode (test | confirm) * @param string $mode Mode (test | confirm)
* @param string $oldemail Old email * @param string $oldemail Target email
* @param string $message Message to send * @param string $message Message to send
* @param string $total Total amount of unpayed invoices * @param string $total Total amount of unpayed invoices
* @param string $userlang Code lang to use for email output. * @param string $userlang Code lang to use for email output.
* @param string $oldcustomer Old customer * @param string $oldtarget Target name
* @param int $duration_value duration value * @param int $duration_value duration value
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$duration_value) function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldtarget,$duration_value)
{ {
global $conf,$langs; global $conf,$langs;
@ -201,17 +235,20 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura
$newlangs->load("contracts"); $newlangs->load("contracts");
if ($duration_value) if ($duration_value)
$title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value); {
if ($duration_value > 0) $title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value);
else $title=$newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg",$duration_value);
}
else else
$title= $newlangs->transnoentities("ListOfServicesToExpire"); $title= $newlangs->transnoentities("ListOfServicesToExpire");
$subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$title; $subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT)?$title:$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_SUBJECT);
$sendto = $oldemail; $sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM; $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
$msgishtml = -1; $msgishtml = -1;
print "- Send email for ".$oldcustomer."(".$oldemail."), total: ".$total."\n"; print "- Send email to '".$oldtarget."' (".$oldemail."), total: ".$total."\n";
dol_syslog("email_expire_services_to_customers.php: send mail to ".$oldemail); dol_syslog("email_expire_services_to_customers.php: send mail to ".$oldemail);
$usehtml=0; $usehtml=0;
@ -227,10 +264,9 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura
{ {
$allmessage.= "Dear customer".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n"); $allmessage.= "Dear customer".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Please, find a summary of the services contracted by you that are about to expire.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n"); $allmessage.= "Please, find a summary of the services contracted by you that are about to expire.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Note: This list contains only services to expire.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
} }
$allmessage.= $message.($usehtml?"<br>\n":"\n"); $allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n"); //$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");
if (! empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER)) if (! empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER))
{ {
$allmessage.=$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER; $allmessage.=$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_CUSTOMERS_FOOTER;
@ -271,6 +307,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldcustomer,$dura
$result=1; $result=1;
} }
unset($newlangs);
if ($result) if ($result)
{ {
return 1; return 1;

View File

@ -38,7 +38,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm')))
{ {
print "Usage: $script_file [test|confirm] [delay]\n"; print "Usage: $script_file (test|confirm) [delay]\n";
print "\n"; print "\n";
print "Send an email to remind all contracts services to expire, to users that are sale representative for.\n"; print "Send an email to remind all contracts services to expire, to users that are sale representative for.\n";
print "If you choose 'test' mode, no emails are sent.\n"; print "If you choose 'test' mode, no emails are sent.\n";
@ -71,20 +71,18 @@ dol_syslog($script_file." launched with arg ".join(',',$argv));
$now=dol_now('tzserver'); $now=dol_now('tzserver');
$duration_value=isset($argv[2])?$argv[2]:'none'; $duration_value=isset($argv[2])?$argv[2]:'none';
print $script_file." launched with mode ".$mode.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n"; print $script_file." launched with mode ".$mode." default lang=".$langs->defaultlang.(is_numeric($duration_value)?" delay=".$duration_value:"")."\n";
if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1; if ($mode != 'confirm') $conf->global->MAIN_DISABLE_ALL_MAILS=1;
$sql = "SELECT DISTINCT s.nom, c.ref, cd.date_fin_validite, cd.total_ttc, p.label label, c.fk_soc,u.rowid AS uid, u.lastname, u.firstname, u.email, u.lang"; $sql = "SELECT DISTINCT c.ref, c.fk_soc, cd.date_fin_validite, cd.total_ttc, cd.description as description, p.label as plabel, s.nom as name, s.email, s.default_lang,";
$sql .= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."contrat AS c, ".MAIN_DB_PREFIX."contratdet AS cd"; $sql.= " u.rowid as uid, u.lastname, u.firstname, u.email, u.lang";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product, ".MAIN_DB_PREFIX."societe_commerciaux AS sc, ".MAIN_DB_PREFIX."user AS u"; $sql.= " FROM ".MAIN_DB_PREFIX."societe AS s, ".MAIN_DB_PREFIX."contrat AS c, ".MAIN_DB_PREFIX."contratdet AS cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product AS p ON p.rowid = cd.fk_product, ".MAIN_DB_PREFIX."societe_commerciaux AS sc, ".MAIN_DB_PREFIX."user AS u";
$sql .= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5"; $sql.= " WHERE s.rowid = c.fk_soc AND c.rowid = cd.fk_contrat AND c.statut > 0 AND cd.statut<5";
if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'"; if (is_numeric($duration_value)) $sql .= " AND cd.date_fin_validite < '".$db->idate(dol_time_plus_duree($now, $duration_value, "d"))."'";
$sql.= " AND sc.fk_soc = s.rowid AND sc.fk_user = u.rowid";
$sql .= " AND sc.fk_soc = s.rowid AND sc.fk_user = u.rowid"; $sql .= " ORDER BY u.email ASC, s.rowid ASC, c.ref ASC"; // Order by email to allow one message per email
$sql .= " ORDER BY cd.date_fin_validite ASC, s.rowid ASC";
//print $sql; //print $sql;
$resql=$db->query($sql); $resql=$db->query($sql);
@ -131,19 +129,23 @@ if ($resql)
$outputlangs->setDefaultLang(empty($obj->lang)?$langs->defaultlang:$obj->lang); // By default language of sale representative $outputlangs->setDefaultLang(empty($obj->lang)?$langs->defaultlang:$obj->lang); // By default language of sale representative
$outputlangs->load("bills"); $outputlangs->load("bills");
$outputlangs->load("main"); $outputlangs->load("main");
$outputlangs->load("contracts");
$outputlangs->load("products");
if (dol_strlen($obj->email)) if (dol_strlen($obj->email))
{ {
$message .= $langs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".$obj->label." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency).") ".$obj->nom.", ".$langs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n"; $message .= $outputlangs->trans("Contract")." ".$obj->ref.": ".$langs->trans("Service")." ".dol_concatdesc($obj->plabel,$obj->description)." (".price($obj->total_ttc,0,$outputlangs,0,0,-1,$conf->currency).") ".$obj->name.", ".$outputlangs->trans("DateEndPlannedShort")." ".dol_print_date($db->jdate($obj->date_fin_validite),'day')."\n\n";
dol_syslog("email_expire_services_to_representatives.php: ".$obj->email); dol_syslog("email_expire_services_to_representatives.php: ".$obj->email);
$foundtoprocess++; $foundtoprocess++;
} }
print "Service to expire ".$obj->ref.", label ".$obj->label.", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day')." (linked to company ".$obj->nom.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): "; print "Service to expire ".$obj->ref.", label ".dol_concatdesc($obj->plabel,$obj->description).", due date ".dol_print_date($db->jdate($obj->date_fin_validite),'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email."): ";
if (dol_strlen($obj->email)) print "qualified."; if (dol_strlen($obj->email)) print "qualified.";
else print "disqualified (no email)."; else print "disqualified (no email).";
print "\n"; print "\n";
$total += $obj->total_ttc; unset($outputlangs);
$total += $obj->total_ttc;
$i++; $i++;
} }
@ -200,11 +202,14 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
$newlangs->load("contracts"); $newlangs->load("contracts");
if ($duration_value) if ($duration_value)
$title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value); {
if ($duration_value > 0) $title=$newlangs->transnoentities("ListOfServicesToExpireWithDuration",$duration_value);
else $title=$newlangs->transnoentities("ListOfServicesToExpireWithDurationNeg",$duration_value);
}
else else
$title= $newlangs->transnoentities("ListOfServicesToExpire"); $title= $newlangs->transnoentities("ListOfServicesToExpire");
$subject = "[".(empty($conf->global->MAIN_APPLICATION_TITLE)?'Dolibarr':$conf->global->MAIN_APPLICATION_TITLE)."] ".$title; $subject = (empty($conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT)?$title:$conf->global->SCRIPT_EMAIL_EXPIRE_SERVICES_SALESREPRESENTATIVES_SUBJECT);
$sendto = $oldemail; $sendto = $oldemail;
$from = $conf->global->MAIN_MAIL_EMAIL_FROM; $from = $conf->global->MAIN_MAIL_EMAIL_FROM;
$errorsto = $conf->global->MAIN_MAIL_ERRORS_TO; $errorsto = $conf->global->MAIN_MAIL_ERRORS_TO;
@ -225,7 +230,7 @@ function envoi_mail($mode,$oldemail,$message,$total,$userlang,$oldsalerepresenta
else else
{ {
$allmessage.= $title.($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n"); $allmessage.= $title.($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
$allmessage.= "Note: This list contains only services of contracts for third parties you are linked to as a sale representative.".($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n"); $allmessage.= $newlangs->transnoentities("NoteListOfYourExpiredServices").($usehtml?"<br>\n":"\n").($usehtml?"<br>\n":"\n");
} }
$allmessage.= $message.($usehtml?"<br>\n":"\n"); $allmessage.= $message.($usehtml?"<br>\n":"\n");
$allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n"); $allmessage.= $langs->trans("Total")." = ".price($total,0,$userlang,0,0,-1,$conf->currency).($usehtml?"<br>\n":"\n");

View File

@ -160,7 +160,7 @@ if ($resql)
dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message); dol_syslog("email_unpaid_invoices_to_customers.php: ".$newemail." ".$message);
$foundtoprocess++; $foundtoprocess++;
} }
print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.",":"")." email ".$newemail." lang ".$outputlangs->defaultlang.": "; print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day').", customer id ".$obj->sid." ".$obj->name.", ".($obj->cid?"contact id ".$obj->cid." ".$obj->clastname." ".$obj->cfirstname.", ":"")."email ".$newemail.", lang ".$outputlangs->defaultlang.": ";
if (dol_strlen($newemail)) print "qualified."; if (dol_strlen($newemail)) print "qualified.";
else print "disqualified (no email)."; else print "disqualified (no email).";
print "\n"; print "\n";

View File

@ -38,7 +38,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm'))) if (! isset($argv[1]) || ! $argv[1] || ! in_array($argv[1],array('test','confirm')))
{ {
print "Usage: $script_file [test|confirm] [delay]\n"; print "Usage: $script_file (test|confirm) [delay]\n";
print "\n"; print "\n";
print "Send an email to users to remind all unpaid customer invoices user is sale representative for.\n"; print "Send an email to users to remind all unpaid customer invoices user is sale representative for.\n";
print "If you choose 'test' mode, no emails are sent.\n"; print "If you choose 'test' mode, no emails are sent.\n";
@ -125,7 +125,7 @@ if ($resql)
$total = 0; $total = 0;
$foundtoprocess = 0; $foundtoprocess = 0;
$salerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname); $salerepresentative=dolGetFirstLastname($obj->firstname, $obj->lastname);
if (empty($obj->email)) print "Warning: Sal representative ".$salerepresentative." has no email. Notice disabled.\n"; if (empty($obj->email)) print "Warning: Sale representative ".$salerepresentative." has no email. Notice disabled.\n";
} }
// Define line content // Define line content
@ -140,7 +140,7 @@ if ($resql)
dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email); dol_syslog("email_unpaid_invoices_to_representatives.php: ".$obj->email);
$foundtoprocess++; $foundtoprocess++;
} }
print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email." lang ".$outputlangs->defaultlang."): "; print "Unpaid invoice ".$obj->facnumber.", price ".price2num($obj->total_ttc).", due date ".dol_print_date($db->jdate($obj->due_date),'day')." (linked to company ".$obj->name.", sale representative ".dolGetFirstLastname($obj->firstname, $obj->lastname).", email ".$obj->email.", lang ".$outputlangs->defaultlang."): ";
if (dol_strlen($obj->email)) print "qualified."; if (dol_strlen($obj->email)) print "qualified.";
else print "disqualified (no email)."; else print "disqualified (no email).";
print "\n"; print "\n";

0
scripts/withdrawals/build_withdrawal_file.php Normal file → Executable file
View File

View File

@ -151,9 +151,75 @@ class ScriptsTest extends PHPUnit_Framework_TestCase
return $result; return $result;
} }
/**
* testCompany
*
* @depends testBank
* @return string
*/
public function testCompany()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
/*
$script=dirname(__FILE__).'/../../scripts/company/sync_contacts_dolibarr_2ldap now';
$result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.');
$this->assertEquals($returnvar,255);
*/
return $result;
}
/**
* testContracts
*
* @depends testCompany
* @return string
*/
public function testContracts()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test thirdparties';
$result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($returnvar,0,'email_expire_services_to_customers.php thirdparties');
$script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_customers.php test contacts -30';
$result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($returnvar,0,'email_expire_services_to_customers.php contacts');
$script=dirname(__FILE__).'/../../scripts/contracts/email_expire_services_to_representatives.php test -30';
$result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($returnvar,0,'email_expire_services_to_representatives.php');
return $result;
}
/** /**
* testInvoices * testInvoices
* *
* @depends testContracts
* @return string * @return string
*/ */
public function testInvoices() public function testInvoices()
@ -166,11 +232,24 @@ class ScriptsTest extends PHPUnit_Framework_TestCase
$script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties'; $script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test thirdparties';
$result=exec($script, $output, $returnvar); $result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n"; print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n"; print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($returnvar,0); $this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties');
$script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_customers.php test contacts -30';
$result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php contacts');
$script=dirname(__FILE__).'/../../scripts/invoices/email_unpaid_invoices_to_representatives.php test thirdparties';
$result=exec($script, $output, $returnvar);
print __METHOD__." result=".$result."\n";
print __METHOD__." output=".join("\n",$output)."\n";
print __METHOD__." returnvar=".$returnvar."\n";
$this->assertEquals($returnvar,0,'email_unpaid_invoices_to_customers.php thirdparties');
return $result; return $result;
} }