Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into mko149
This commit is contained in:
commit
e0d037dae5
@ -30,6 +30,9 @@ For users:
|
||||
- New: Add option MAIN_GENERATE_DOCUMENT_WITH_PICTURE.
|
||||
- New: Add option excludethirdparties and onlythirdparties into merge pdf scripts.
|
||||
- Qual: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
||||
- New : [ task #925 ] Add ODT document generation for Tasks in project module
|
||||
- New : [ task #924 ] Add numbering rule on task
|
||||
|
||||
|
||||
For translators:
|
||||
- Normalized sort order of all languages files with english reference files.
|
||||
|
||||
@ -8,7 +8,7 @@ script to build a package, ready to be distributed,
|
||||
with format .DEB (for Debian, Ubuntu, ...).
|
||||
|
||||
# To build a debian package, you need first
|
||||
# apt-get -i debhelper dpkg-source gpg lintian
|
||||
# apt-get -i debhelper dpkg-source gpg lintian git-buildpackage
|
||||
|
||||
|
||||
# This is standard command to work on Debian packaging:
|
||||
@ -59,11 +59,53 @@ http://bugs.debian.org/package
|
||||
|
||||
|
||||
##########################################################
|
||||
|
||||
To create a gpg key for email used into changelog
|
||||
Check your existing keys/emails
|
||||
* gpg --list-key
|
||||
Generate a new one
|
||||
* gpg --gen-key
|
||||
|
||||
|
||||
To use Alioth.debian.org
|
||||
Create a login
|
||||
Setup your ssh as described into page: http://wiki.debian.org/Alioth/SSH
|
||||
Ask to be included into project collab-maint: http://alioth.debian.org/projects/collab-maint/
|
||||
Then you can git clone tcpdf
|
||||
git clone git.debian.org:/git/collab-maint/tcpdf.git
|
||||
* Create a login
|
||||
* Setup your ssh as described into page: http://wiki.debian.org/Alioth/SSH
|
||||
* Ask to be included into project collab-maint: http://alioth.debian.org/projects/collab-maint/
|
||||
|
||||
|
||||
To update tcpdf package:
|
||||
|
||||
* You can git clone tcpdf
|
||||
git clone git.debian.org:/git/collab-maint/tcpdf.git [tcpdf-debian]
|
||||
|
||||
* Into root dir, launch:
|
||||
debian/get-orig-source.sh
|
||||
|
||||
* Créer un fichier ~/.gpb.conf par
|
||||
cat >~/.gbp.conf <<END
|
||||
[DEFAULT]
|
||||
pristine-tar = True
|
||||
|
||||
[git-buildpackage]
|
||||
sign-tags = True
|
||||
export-dir = ../build-area/
|
||||
|
||||
[git-import-orig]
|
||||
filter-pristine-tar = True
|
||||
END
|
||||
|
||||
* Create branch upstream from origin/upstream
|
||||
|
||||
* Staying into git root directory, run
|
||||
git-import-orig -vv ../tcpdf_6.0.020+dfsg.orig.tar.xz
|
||||
|
||||
* Add an entry into debian/changelog and commit by amending previous commit.
|
||||
|
||||
* We try to build package
|
||||
git-buildpackage -us -uc
|
||||
|
||||
* If package .deb is ok:
|
||||
git-buildpackage --git-tag
|
||||
git push
|
||||
git push --tags
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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
|
||||
@ -79,6 +80,13 @@ if ($id || $ref)
|
||||
$dbtablename = 'adherent';
|
||||
$fieldid = ! empty($ref)?'ref':'rowid';
|
||||
}
|
||||
elseif ($type == 4) {
|
||||
$elementtype = 'societe';
|
||||
$objecttype = 'contact';
|
||||
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
|
||||
$dbtablename = 'socpeople&societe';
|
||||
$fieldid = ! empty($ref)?'ref':'rowid';
|
||||
}
|
||||
}
|
||||
|
||||
// Security check
|
||||
@ -128,6 +136,13 @@ if (empty($reshook))
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'member';
|
||||
}
|
||||
if ($type == 4 && $user->rights->societe->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'contact';
|
||||
}
|
||||
$cat = new Categorie($db);
|
||||
$result=$cat->fetch($removecat);
|
||||
|
||||
@ -163,6 +178,13 @@ if (empty($reshook))
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'member';
|
||||
}
|
||||
if ($type == 4 && $user->rights->societe->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($objectid);
|
||||
$elementtype = 'contact';
|
||||
}
|
||||
$cat = new Categorie($db);
|
||||
$result=$cat->fetch($parent);
|
||||
|
||||
@ -431,6 +453,154 @@ else if ($id || $ref)
|
||||
|
||||
formCategory($db,$member,3);
|
||||
}
|
||||
if ($type == 4)
|
||||
{
|
||||
$langs->load("contact");
|
||||
|
||||
/*
|
||||
* Fiche categorie d'contact
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
// Produit
|
||||
$object = new Contact($db);
|
||||
$result = $object->fetch($id, $ref);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
llxHeader("","",$langs->trans("Contact"));
|
||||
|
||||
|
||||
$head=contact_prepare_head($object, $user);
|
||||
$titre=$langs->trans("Contact");
|
||||
$picto='user';
|
||||
dol_fiche_head($head, 'tabCategorie', $titre,0,$picto);
|
||||
|
||||
$rowspan=5;
|
||||
if (! empty($conf->societe->enabled)) $rowspan++;
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td class="valeur">';
|
||||
print $form->showrefnav($object,'rowid');
|
||||
print '</td></tr>';
|
||||
|
||||
// Name
|
||||
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
||||
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
|
||||
|
||||
// Company
|
||||
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
||||
if (!empty($object->thirdparty->id))
|
||||
{
|
||||
print $object->thirdparty->getNomUrl(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("ContactNotLinkedToCompany");
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Civility
|
||||
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
||||
print $object->getCivilityLabel();
|
||||
print '</td></tr>';
|
||||
|
||||
// Role
|
||||
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3">'.$object->poste.'</td>';
|
||||
|
||||
// Address
|
||||
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">';
|
||||
dol_print_address($object->address,'gmap','contact',$object->id);
|
||||
print '</td></tr>';
|
||||
|
||||
// Zip/Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">';
|
||||
print $object->zip;
|
||||
if ($object->zip) print ' ';
|
||||
print $object->town.'</td></tr>';
|
||||
|
||||
// Country
|
||||
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
|
||||
$img=picto_from_langcode($object->country_code);
|
||||
if ($img) print $img.' ';
|
||||
print $object->country;
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
if (empty($conf->global->SOCIETE_DISABLE_STATE))
|
||||
{
|
||||
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$object->state.'</td>';
|
||||
}
|
||||
|
||||
// Phone
|
||||
print '<tr><td>'.$langs->trans("PhonePro").'</td><td>'.dol_print_phone($object->phone_pro,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td>';
|
||||
print '<td>'.$langs->trans("PhonePerso").'</td><td>'.dol_print_phone($object->phone_perso,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($object->phone_mobile,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td>';
|
||||
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($object->fax,$object->country_code,$object->id,$object->socid,'AC_FAX').'</td></tr>';
|
||||
|
||||
// Email
|
||||
print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($object->email,$object->id,$object->socid,'AC_EMAIL').'</td>';
|
||||
if (! empty($conf->mailing->enabled))
|
||||
{
|
||||
$langs->load("mails");
|
||||
print '<td nowrap>'.$langs->trans("NbOfEMailingsReceived").'</td>';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/liste.php?filteremail='.urlencode($object->email).'">'.$object->getNbOfEMailings().'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
// Instant message and no email
|
||||
print '<tr><td>'.$langs->trans("IM").'</td><td>'.$object->jabberid.'</td>';
|
||||
if (!empty($conf->mailing->enabled))
|
||||
{
|
||||
print '<td>'.$langs->trans("No_Email").'</td><td>'.yn($object->no_email).'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="2"> </td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">';
|
||||
print $object->LibPubPriv($object->priv);
|
||||
print '</td></tr>';
|
||||
|
||||
// Note Public
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td><td colspan="3">';
|
||||
print nl2br($object->note_public);
|
||||
print '</td></tr>';
|
||||
|
||||
// Note Private
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">';
|
||||
print nl2br($object->note_private);
|
||||
print '</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||
{
|
||||
print $object->showOptionals($extrafields);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
formCategory($db,$object,4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -451,6 +621,7 @@ function formCategory($db,$object,$typeid,$socid=0)
|
||||
if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort");
|
||||
if ($typeid == 2) $title = $langs->trans("CustomersProspectsCategoriesShort");
|
||||
if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort");
|
||||
if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort");
|
||||
|
||||
// Formulaire ajout dans une categorie
|
||||
print '<br>';
|
||||
@ -490,6 +661,7 @@ function formCategory($db,$object,$typeid,$socid=0)
|
||||
if ($typeid == 1) $title=$langs->trans("CompanyIsInSuppliersCategories");
|
||||
if ($typeid == 2) $title=$langs->trans("CompanyIsInCustomersCategories");
|
||||
if ($typeid == 3) $title=$langs->trans("MemberIsInCategories");
|
||||
if ($typeid == 4) $title=$langs->trans("ContactIsInCategories");
|
||||
print "\n";
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="2">'.$title.':</td></tr>';
|
||||
@ -517,6 +689,7 @@ function formCategory($db,$object,$typeid,$socid=0)
|
||||
if ($typeid == 1) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == 2) $permission=$user->rights->societe->creer;
|
||||
if ($typeid == 3) $permission=$user->rights->adherent->creer;
|
||||
if ($typeid == 4) $permission=$user->rights->societe->creer;
|
||||
if ($permission)
|
||||
{
|
||||
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removecat=".$cat->id."'>";
|
||||
@ -544,6 +717,7 @@ function formCategory($db,$object,$typeid,$socid=0)
|
||||
if ($typeid == 1) $title=$langs->trans("CompanyHasNoCategory");
|
||||
if ($typeid == 2) $title=$langs->trans("CompanyHasNoCategory");
|
||||
if ($typeid == 3) $title=$langs->trans("MemberHasNoCategory");
|
||||
if ($typeid == 4) $title=$langs->trans("ContactHasNoCategory");
|
||||
print $title;
|
||||
print "<br/>";
|
||||
}
|
||||
|
||||
@ -378,10 +378,16 @@ class Categorie
|
||||
function add_type($obj,$type)
|
||||
{
|
||||
if ($this->id == -1) return -2;
|
||||
|
||||
if ($type == 'company') $type='societe';
|
||||
if ($type == 'fournisseur') $type='societe';
|
||||
|
||||
$column_name=$type;
|
||||
if ($type=='contact') {
|
||||
$column_name='socpeople';
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$type.")";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$column_name.")";
|
||||
$sql .= " VALUES (".$this->id.", ".$obj->id.")";
|
||||
|
||||
dol_syslog(get_class($this).'::add_type sql='.$sql);
|
||||
@ -413,9 +419,16 @@ class Categorie
|
||||
*/
|
||||
function del_type($obj,$type)
|
||||
{
|
||||
|
||||
if ($type == 'company') $type='societe';
|
||||
if ($type == 'fournisseur') $type='societe';
|
||||
|
||||
$column_name=$type;
|
||||
if ($type=='contact') $column_name='socpeople';
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type;
|
||||
$sql .= " WHERE fk_categorie = ".$this->id;
|
||||
$sql .= " AND fk_".($type=='fournisseur'?'societe':$type)." = ".$obj->id;
|
||||
$sql .= " AND fk_".$column_name." = ".$obj->id;
|
||||
|
||||
dol_syslog(get_class($this).'::del_type sql='.$sql);
|
||||
if ($this->db->query($sql))
|
||||
@ -972,6 +985,7 @@ class Categorie
|
||||
else if ($typeid == 1 || $typeid == 'supplier') { $typeid=1; $table='societe'; $type='fournisseur'; }
|
||||
else if ($typeid == 2 || $typeid == 'customer') { $typeid=2; $table='societe'; $type='societe'; }
|
||||
else if ($typeid == 3 || $typeid == 'member') { $typeid=3; $table='member'; $type='member'; }
|
||||
else if ($typeid == 4 || $typeid == 'contact') { $typeid=4; $table='socpeople'; $type='contact'; }
|
||||
|
||||
$sql = "SELECT ct.fk_categorie, c.label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct, ".MAIN_DB_PREFIX."categorie as c";
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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
|
||||
@ -53,6 +54,7 @@ if ($origin)
|
||||
if ($type == 1) $idSupplierOrigin = $origin;
|
||||
if ($type == 2) $idCompanyOrigin = $origin;
|
||||
if ($type == 3) $idMemberOrigin = $origin;
|
||||
if ($type == 4) $idContactOrigin = $origin;
|
||||
}
|
||||
|
||||
if ($catorigin && $type == 0) $idCatOrigin = $catorigin;
|
||||
@ -98,6 +100,11 @@ if ($action == 'add' && $user->rights->categorie->creer)
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
else if ($idContactOrigin)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
|
||||
@ -170,6 +177,11 @@ if (($action == 'add' || $action == 'confirmed') && $user->rights->categorie->cr
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
}
|
||||
else if ($idContactOrigin)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idContactOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
|
||||
exit;
|
||||
}
|
||||
|
||||
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$type);
|
||||
exit;
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("suppliers");
|
||||
@ -47,6 +48,7 @@ $search_phonemob=GETPOST("search_phonemob");
|
||||
$search_fax=GETPOST("search_fax");
|
||||
$search_email=GETPOST("search_email");
|
||||
$search_priv=GETPOST("search_priv");
|
||||
$search_categ = GETPOST("search_categ",'int');
|
||||
|
||||
$type=GETPOST("type");
|
||||
$view=GETPOST("view");
|
||||
@ -109,6 +111,7 @@ $title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("
|
||||
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
||||
|
||||
$form=new Form($db);
|
||||
$formother=new FormOther($db);
|
||||
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name,";
|
||||
$sql.= " p.rowid as cidp, p.lastname as lastname, p.firstname, p.poste, p.email,";
|
||||
@ -117,6 +120,7 @@ $sql.= " cp.code as country_code";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as cp ON cp.rowid = p.fk_pays";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
|
||||
if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cs ON s.rowid = cs.fk_socpeople"; // We need this table joined to the select in order to filter by categ
|
||||
if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
|
||||
$sql.= ' WHERE p.entity IN ('.getEntity('societe', 1).')';
|
||||
if (!$user->rights->societe->client->voir && !$socid) //restriction
|
||||
@ -139,6 +143,9 @@ else
|
||||
if ($search_priv == '1') $sql .= " AND (p.priv='1' AND p.fk_user_creat=".$user->id.")";
|
||||
}
|
||||
|
||||
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$search_categ;
|
||||
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
|
||||
|
||||
if ($search_lastname) // filter on lastname
|
||||
{
|
||||
$sql .= " AND p.lastname LIKE '%".$db->escape($search_lastname)."%'";
|
||||
@ -235,7 +242,8 @@ if ($result)
|
||||
|
||||
$param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall);
|
||||
$param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_lastname='.urlencode($search_lastname).'&search_firstname='.urlencode($search_firstname).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email);
|
||||
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
|
||||
if (!empty($search_categ)) $param.='&search_categ='.$search_categ;
|
||||
if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv);
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
@ -248,6 +256,19 @@ if ($result)
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
|
||||
if (! empty($conf->categorie->enabled))
|
||||
{
|
||||
$moreforfilter.=$langs->trans('Categories'). ': ';
|
||||
$moreforfilter.=$formother->select_categories(4,$search_categ,'search_categ',1);
|
||||
$moreforfilter.=' ';
|
||||
}
|
||||
if ($moreforfilter)
|
||||
{
|
||||
print '<div class="liste_titre">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname")." ".$langs->trans("or")." ".$langs->trans("EMail")."): ".$sall;
|
||||
|
||||
@ -156,7 +156,7 @@ class FormFile
|
||||
* Show the box with list of available documents for object
|
||||
*
|
||||
* @param string $modulepart propal, facture, facture_fourn, ...
|
||||
* @param string $filename Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if $filedir is already complete)
|
||||
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||
* @param string $filedir Directory to scan
|
||||
* @param string $urlsource Url of origin page (for return)
|
||||
* @param int $genallowed Generation is allowed (1/0 or array of formats)
|
||||
@ -173,10 +173,10 @@ class FormFile
|
||||
* @param string $codelang Default language code to use on lang combo box if multilang is enabled
|
||||
* @return int <0 if KO, number of shown files if OK
|
||||
*/
|
||||
function show_documents($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
|
||||
function show_documents($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='')
|
||||
{
|
||||
$this->numoffiles=0;
|
||||
print $this->showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang);
|
||||
print $this->showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed,$modelselected,$allowgenifempty,$forcenomultilang,$iconPDF,$maxfilenamelength,$noform,$param,$title,$buttonlabel,$codelang);
|
||||
return $this->numoffiles;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ class FormFile
|
||||
* This also set the property $this->numoffiles
|
||||
*
|
||||
* @param string $modulepart Module the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule_temp', ...)
|
||||
* @param string $filename Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if $filedir is already complete)
|
||||
* @param string $modulesubdir Existing (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||
* @param string $filedir Directory to scan
|
||||
* @param string $urlsource Url of origin page (for return)
|
||||
* @param int $genallowed Generation is allowed (1/0 or array list of templates)
|
||||
@ -203,7 +203,7 @@ class FormFile
|
||||
* @param string $morepicto Add more HTML content into cell with picto
|
||||
* @return string Output string with HTML array of documents (might be empty string)
|
||||
*/
|
||||
function showdocuments($modulepart,$filename,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='')
|
||||
function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$maxfilenamelength=28,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='')
|
||||
{
|
||||
global $langs,$conf,$hookmanager;
|
||||
global $bc;
|
||||
@ -213,7 +213,7 @@ class FormFile
|
||||
|
||||
// For backward compatibility
|
||||
if (! empty($iconPDF)) {
|
||||
return $this->getDocumentsLink($modulepart, $filename, $filedir);
|
||||
return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir);
|
||||
}
|
||||
$printer = ($user->rights->printipp->read && $conf->printipp->enabled)?true:false;
|
||||
$hookmanager->initHooks(array('formfile'));
|
||||
@ -309,6 +309,15 @@ class FormFile
|
||||
$modellist=ModelePDFProjects::liste_modeles($this->db);
|
||||
}
|
||||
}
|
||||
elseif ($modulepart == 'project_task')
|
||||
{
|
||||
if (is_array($genallowed)) $modellist=$genallowed;
|
||||
else
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
|
||||
$modellist=ModelePDFTask::liste_modeles($this->db);
|
||||
}
|
||||
}
|
||||
elseif ($modulepart == 'export')
|
||||
{
|
||||
if (is_array($genallowed)) $modellist=$genallowed;
|
||||
@ -486,9 +495,9 @@ class FormFile
|
||||
|
||||
// Define relative path for download link (depends on module)
|
||||
$relativepath=$file["name"]; // Cas general
|
||||
if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture...
|
||||
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
|
||||
// Autre cas
|
||||
if ($modulepart == 'donation') { $relativepath = get_exdir($filename,2).$file["name"]; }
|
||||
if ($modulepart == 'donation') { $relativepath = get_exdir($modulesubdir,2).$file["name"]; }
|
||||
if ($modulepart == 'export') { $relativepath = $file["name"]; }
|
||||
|
||||
$out.= "<tr ".$bc[$var].">";
|
||||
@ -571,11 +580,11 @@ class FormFile
|
||||
* Show only Document icon with link
|
||||
*
|
||||
* @param string $modulepart propal, facture, facture_fourn, ...
|
||||
* @param string $filename Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if $filedir is already complete)
|
||||
* @param string $modulesubdir Sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
|
||||
* @param string $filedir Directory to scan
|
||||
* @return string Output string with HTML link of documents (might be empty string)
|
||||
*/
|
||||
function getDocumentsLink($modulepart, $filename, $filedir)
|
||||
function getDocumentsLink($modulepart, $modulesubdir, $filedir)
|
||||
{
|
||||
if (! function_exists('dol_dir_list')) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
@ -585,10 +594,10 @@ class FormFile
|
||||
|
||||
$this->numoffiles=0;
|
||||
|
||||
$file_list=dol_dir_list($filedir, 'files', 0, $filename.'.pdf', '\.meta$|\.png$');
|
||||
$file_list=dol_dir_list($filedir, 'files', 0, $modulesubdir.'.pdf', '\.meta$|\.png$');
|
||||
|
||||
// For ajax treatment
|
||||
$out.= '<div id="gen_pdf_'.$filename.'" class="linkobject hideobject">'.img_picto('', 'refresh').'</div>'."\n";
|
||||
$out.= '<div id="gen_pdf_'.$modulesubdir.'" class="linkobject hideobject">'.img_picto('', 'refresh').'</div>'."\n";
|
||||
|
||||
if (! empty($file_list))
|
||||
{
|
||||
@ -597,10 +606,10 @@ class FormFile
|
||||
{
|
||||
// Define relative path for download link (depends on module)
|
||||
$relativepath=$file["name"]; // Cas general
|
||||
if ($filename) $relativepath=$filename."/".$file["name"]; // Cas propal, facture...
|
||||
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
|
||||
// Autre cas
|
||||
if ($modulepart == 'donation') {
|
||||
$relativepath = get_exdir($filename,2).$file["name"];
|
||||
$relativepath = get_exdir($modulesubdir,2).$file["name"];
|
||||
}
|
||||
if ($modulepart == 'export') {
|
||||
$relativepath = $file["name"];
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
*/
|
||||
function contact_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
global $langs, $conf, $user;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
@ -72,6 +72,15 @@ function contact_prepare_head($object)
|
||||
$head[$h][2] = 'note';
|
||||
$h++;
|
||||
|
||||
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire))
|
||||
{
|
||||
$type = 4;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/categories/categorie.php?id='.$object->id."&type=".$type;
|
||||
$head[$h][1] = $langs->trans('Categories');
|
||||
$head[$h][2] = 'category';
|
||||
$h++;
|
||||
}
|
||||
|
||||
// Info
|
||||
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
|
||||
@ -281,12 +281,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
|
||||
print '<td>';
|
||||
if ($showlineingray)
|
||||
{
|
||||
print '<i>'.img_object('','projecttask').' '.$lines[$i]->id.'</i>';
|
||||
print '<i>'.img_object('','projecttask').' '.$lines[$i]->ref.'</i>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$taskstatic->id=$lines[$i]->id;
|
||||
$taskstatic->ref=$lines[$i]->id;
|
||||
$taskstatic->ref=$lines[$i]->ref;
|
||||
$taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:'');
|
||||
print $taskstatic->getNomUrl(1,($showproject?'':'withproject'));
|
||||
}
|
||||
|
||||
248
htdocs/core/modules/mailings/contacts4.modules.php
Normal file
248
htdocs/core/modules/mailings/contacts4.modules.php
Normal file
@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 François Cerbelle <francois@cerbelle.net>
|
||||
* Copyright (C) 2013 florian HENRY <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/mailings/contacts4.modules.php
|
||||
* \ingroup mailing
|
||||
* \brief Provides a list of recipients for mailing module
|
||||
*/
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
|
||||
|
||||
|
||||
/**
|
||||
* \class mailing_contacts4
|
||||
* \brief Class to manage a list of personalised recipients for mailing feature
|
||||
*/
|
||||
class mailing_contacts4 extends MailingTargets
|
||||
{
|
||||
var $name='ContactsByCategory';
|
||||
// This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found
|
||||
var $desc='Add contacts by category';
|
||||
var $require_admin=0;
|
||||
|
||||
var $require_module=array();
|
||||
var $picto='contact';
|
||||
var $db;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db=$db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoie url lien vers fiche de la source du destinataire du mailing
|
||||
*
|
||||
* @param int $id ID
|
||||
* @return string Url lien
|
||||
*/
|
||||
function url($id)
|
||||
{
|
||||
return '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$id.'">'.img_object('',"contact").'</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main function that returns the array of emails
|
||||
*
|
||||
* @param int $mailing_id Id of mailing. No need to use it.
|
||||
* @param array $filtersarray Category
|
||||
* @return int <0 if error, number of emails added if ok
|
||||
*/
|
||||
function add_to_target($mailing_id,$filtersarray=array())
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$target = array();
|
||||
|
||||
// La requete doit retourner: id, email, fk_contact, name, firstname, other
|
||||
$sql = "SELECT sp.rowid as id, sp.email as email, sp.rowid as fk_contact,";
|
||||
$sql.= " sp.lastname, sp.firstname, sp.civilite,";
|
||||
$sql.= " s.nom as companyname";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
|
||||
if ($filtersarray[0] <> 'all')$sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie_contact as cs ON cs.fk_socpeople=sp.rowid";
|
||||
if ($filtersarray[0] <> 'all') $sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc";
|
||||
$sql.= " WHERE sp.email != ''"; // Note that null != '' is false
|
||||
$sql.= " AND sp.no_email = 0";
|
||||
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
|
||||
if ($filtersarray[0] <> 'all') $sql.= " AND c.label = '".$this->db->escape($filtersarray[0])."'";
|
||||
$sql.= " ORDER BY sp.lastname, sp.firstname";
|
||||
|
||||
dol_syslog(get_class($this).':: add_to_target sql='.$sql,LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj= $this->db->fetch_object($resql);
|
||||
$target[] = array(
|
||||
'email' => $obj->email,
|
||||
'fk_contact' => $obj->fk_contact,
|
||||
'lastname' => $obj->lastname,
|
||||
'firstname' => $obj->firstname,
|
||||
'other' =>
|
||||
($langs->transnoentities("ThirdParty").'='.$obj->companyname).';'.
|
||||
($langs->transnoentities("UserTitle").'='.($obj->civilite?$langs->transnoentities("Civility".$obj->civilite):'')),
|
||||
'source_url' => $this->url($obj->id),
|
||||
'source_id' => $obj->id,
|
||||
'source_type' => 'contact'
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
}else {
|
||||
$this->error=$this->db->lasterrno();
|
||||
dol_syslog(get_class($this)."Error sql=".$sql." ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return parent::add_to_target($mailing_id, $target);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On the main mailing area, there is a box with statistics.
|
||||
* If you want to add a line in this report you must provide an
|
||||
* array of SQL request that returns two field:
|
||||
* One called "label", One called "nb".
|
||||
*
|
||||
* @return array Array with SQL requests
|
||||
*/
|
||||
function getSqlArrayForStats()
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$statssql=array();
|
||||
/*for ($i=0; $i<5; $i++) {
|
||||
$statssql[$i] = "SELECT c.label, count(sp.rowid) AS nb";
|
||||
$statssql[$i].= " FROM ".MAIN_DB_PREFIX."socpeople as sp,";
|
||||
$statssql[$i].= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$statssql[$i].= " ".MAIN_DB_PREFIX."categorie as c,";
|
||||
$statssql[$i].= " ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
$statssql[$i].= " WHERE s.rowid = sp.fk_soc";
|
||||
$statssql[$i].= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$statssql[$i].= " AND sp.entity IN (".getEntity('societe', 1).")";
|
||||
$statssql[$i].= " AND cs.fk_categorie = c.rowid";
|
||||
$statssql[$i].= " AND cs.fk_societe = sp.fk_soc";
|
||||
$statssql[$i].= " GROUP BY c.label";
|
||||
$statssql[$i].= " ORDER BY nb DESC";
|
||||
$statssql[$i].= " LIMIT $i,1";
|
||||
}*/
|
||||
|
||||
return $statssql;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return here number of distinct emails returned by your selector.
|
||||
*
|
||||
* @param string $sql Requete sql de comptage
|
||||
* @return int Number of recipients
|
||||
*/
|
||||
function getNbOfRecipients($sql='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// We must report here number of contacts when absolutely no filter selected (so all contacts).
|
||||
// Number with a filter are show in the combo list for each filter.
|
||||
// If we want a filter "is inside at least one category", we must add it into formFilter
|
||||
$sql = "SELECT count(distinct(c.email)) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||
$sql.= " WHERE c.entity IN (".getEntity('societe', 1).")";
|
||||
$sql.= " AND c.email != ''"; // Note that null != '' is false
|
||||
$sql.= " AND c.no_email = 0";
|
||||
/*
|
||||
$sql = "SELECT count(distinct(sp.email)) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."societe as s,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."categorie as c,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."categorie_societe as cs";
|
||||
$sql.= " WHERE s.rowid = sp.fk_soc";
|
||||
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
|
||||
$sql.= " AND sp.email != ''"; // Note that null != '' is false
|
||||
$sql.= " AND cs.fk_categorie = c.rowid";
|
||||
$sql.= " AND cs.fk_societe = sp.fk_soc";
|
||||
*/
|
||||
// La requete doit retourner un champ "nb" pour etre comprise
|
||||
// par parent::getNbOfRecipients
|
||||
return parent::getNbOfRecipients($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is to add a form filter to provide variant of selector
|
||||
* If used, the HTML select must be called "filter".
|
||||
*
|
||||
* @return string A html select zone
|
||||
*/
|
||||
function formFilter()
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$langs->load("companies");
|
||||
|
||||
$sql = "SELECT c.label, count(distinct(sp.email)) AS nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie_contact as cs ON cs.fk_socpeople=sp.rowid";
|
||||
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
|
||||
$sql.= " WHERE sp.email != ''"; // Note that null != '' is false
|
||||
$sql.= " AND sp.no_email = 0";
|
||||
$sql.= " AND sp.entity IN (".getEntity('societe', 1).")";
|
||||
$sql.= " GROUP BY c.label";
|
||||
$sql.= " ORDER BY c.label";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
dol_syslog(get_class($this).':: formFilter sql='.$sql,LOG_DEBUG);
|
||||
if ($resql) {
|
||||
$s='';
|
||||
$s.='<select name="filter" class="flat">';
|
||||
$s.='<option value="all"></option>';
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$s.='<option value="'.$obj->label.'">'.$obj->label.' ('.$obj->nb.')</option>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$s.='</select>';
|
||||
return $s;
|
||||
}
|
||||
else {
|
||||
$this->error=$this->db->lasterrno();
|
||||
dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -169,7 +169,6 @@ class MailingTargets // This can't be abstract as it is used for some method
|
||||
$sql .= "'".$this->db->escape($targetarray['email'])."',";
|
||||
$sql .= "'".$this->db->escape($targetarray['other'])."',";
|
||||
$sql .= "'".$this->db->escape($targetarray['source_url'])."',";
|
||||
$sql .= "'".$this->db->escape($targetarray['source_id'])."',";
|
||||
$sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
|
||||
if (! empty($conf->global->MAILING_EMAIL_UNSUBSCRIBE)) {
|
||||
$sql .= "'".$this->db->escape(md5($targetarray['email'].';'.$targetarray['name'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
|
||||
|
||||
@ -163,6 +163,84 @@ class modCategorie extends DolibarrModules
|
||||
$this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';
|
||||
$this->export_sql_end[$r] .=' AND u.entity = '.$conf->entity;
|
||||
$this->export_sql_end[$r] .=' AND u.type = 3'; // Supplier categories
|
||||
|
||||
$r = 0;
|
||||
$r ++;
|
||||
$this->export_code [$r] = 'category_'.$r;
|
||||
$this->export_label [$r] = 'CatContactList';
|
||||
$this->export_icon [$r] = 'category';
|
||||
$this->export_enabled [$r] = '$conf->societe->enabled';
|
||||
$this->export_permission [$r] = array (
|
||||
array (
|
||||
"categorie",
|
||||
"lire"
|
||||
),
|
||||
array (
|
||||
"societe",
|
||||
"lire"
|
||||
)
|
||||
);
|
||||
$this->export_fields_array [$r] = array (
|
||||
'u.rowid' => "CategId",
|
||||
'u.label' => "Label",
|
||||
'u.description' => "Description",
|
||||
'p.rowid' => 'ContactId',
|
||||
'p.civilite' => 'Civitity',
|
||||
'p.lastname' => 'LastName',
|
||||
'p.firstname' => 'Firstname',
|
||||
'p.address' => 'Address',
|
||||
'p.zip' => 'Zip',
|
||||
'p.town' => 'Town',
|
||||
'country.code' => 'CountryCode',
|
||||
'country.libelle' => 'Country',
|
||||
'p.birthday' => 'DateToBirth',
|
||||
'p.poste' => 'PostOrFunction',
|
||||
'p.phone' => 'Phone',
|
||||
'p.phone_perso' => 'PhonePerso',
|
||||
'p.phone_mobile' => 'PhoneMobile',
|
||||
'p.fax' => 'Fax',
|
||||
'p.email' => 'Email',
|
||||
'p.note_private' => 'NotePrivate',
|
||||
'p.note_public' => 'NotePublic'
|
||||
);
|
||||
$this->export_TypeFields_array [$r] = array (
|
||||
'u.label' => "Text",
|
||||
'u.description' => "Text",
|
||||
'p.rowid' => 'List:contact:lastname',
|
||||
'p.lastname' => 'Text',
|
||||
'p.firstname' => 'Text'
|
||||
);
|
||||
$this->export_entities_array [$r] = array (
|
||||
'u.rowid' => "category",
|
||||
'u.label' => "category",
|
||||
'u.description' => "category",
|
||||
'p.rowid' => 'contact',
|
||||
'p.rowid' => 'contact',
|
||||
'p.civilite' => 'contact',
|
||||
'p.lastname' => 'contact',
|
||||
'p.firstname' => 'contact',
|
||||
'p.address' => 'contact',
|
||||
'p.zip' => 'contact',
|
||||
'p.town' => 'contact',
|
||||
'country.code' => 'contact',
|
||||
'country.libelle' => 'contact',
|
||||
'p.birthday' => 'contact',
|
||||
'p.poste' => 'contact',
|
||||
'p.phone' => 'contact',
|
||||
'p.phone_perso' => 'contact',
|
||||
'p.phone_mobile' => 'contact',
|
||||
'p.fax' => 'contact',
|
||||
'p.email' => 'contact',
|
||||
'p.note_private' => 'contact',
|
||||
'p.note_public' => 'contact'
|
||||
); // We define here only fields that use another picto
|
||||
$this->export_sql_start [$r] = 'SELECT DISTINCT ';
|
||||
$this->export_sql_end [$r] .= ' FROM ' . MAIN_DB_PREFIX . 'categorie as u ';
|
||||
$this->export_sql_end [$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'categorie_contact as cp ON u.rowid = cp.fk_categorie ';
|
||||
$this->export_sql_end [$r] .= ' INNER JOIN ' . MAIN_DB_PREFIX . 'socpeople as p ON cp.fk_socpeople = p.rowid ';
|
||||
$this->export_sql_end [$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_pays as country ON p.fk_pays = country.rowid';
|
||||
$this->export_sql_end [$r] .= ' WHERE u.entity = ' . $conf->entity;
|
||||
$this->export_sql_end [$r] .= ' AND u.type = 4'; // contact categories
|
||||
|
||||
// Imports
|
||||
//--------
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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
|
||||
@ -75,14 +76,14 @@ class modProjet extends DolibarrModules
|
||||
$this->const[$r][0] = "PROJECT_ADDON_PDF";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "baleine";
|
||||
$this->const[$r][3] = 'Nom du gestionnaire de generation des projets en PDF';
|
||||
$this->const[$r][3] = 'Name of PDF/ODT project manager class';
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "PROJECT_ADDON";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "mod_project_simple";
|
||||
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des projets';
|
||||
$this->const[$r][3] = 'Name of Numbering Rule project manager class';
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
@ -92,6 +93,27 @@ class modProjet extends DolibarrModules
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/projects";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
|
||||
$this->const[$r][0] = "PROJECT_TASK_ADDON_PDF";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "";
|
||||
$this->const[$r][3] = 'Name of PDF/ODT tasks manager class';
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$this->const[$r][0] = "PROJECT_TASK_ADDON";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "mod_task_simple";
|
||||
$this->const[$r][3] = 'Name of Numbering Rule task manager class';
|
||||
$this->const[$r][4] = 0;
|
||||
$r++;
|
||||
|
||||
$r++;
|
||||
$this->const[$r][0] = "PROJECT_TASK_ADDON_PDF_ODT_PATH";
|
||||
$this->const[$r][1] = "chaine";
|
||||
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/tasks";
|
||||
$this->const[$r][3] = "";
|
||||
$this->const[$r][4] = 0;
|
||||
|
||||
// Boxes
|
||||
$this->boxes = array();
|
||||
|
||||
152
htdocs/core/modules/project/task/mod_task_simple.php
Normal file
152
htdocs/core/modules/project/task/mod_task_simple.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/project/mod_project_simple.php
|
||||
* \ingroup project
|
||||
* \brief File with class to manage the numbering module Simple for project references
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage the numbering module Simple for project references
|
||||
*/
|
||||
class mod_task_simple extends ModeleNumRefTask
|
||||
{
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
var $prefix='TK';
|
||||
var $error='';
|
||||
var $nom = "Simple";
|
||||
|
||||
|
||||
/**
|
||||
* Return description of numbering module
|
||||
*
|
||||
* @return string Text with description
|
||||
*/
|
||||
function info()
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an example of numbering module values
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
return $this->prefix."0501-0001";
|
||||
}
|
||||
|
||||
|
||||
/** Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
*
|
||||
* @return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$coyymm=''; $max='';
|
||||
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
|
||||
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; }
|
||||
}
|
||||
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$langs->load("errors");
|
||||
$this->error=$langs->trans('ErrorNumRefModel',$max);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return next value
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Task $Task Object Task
|
||||
* @return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc,$task)
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
// D'abord on recupere la valeur max
|
||||
$posindice=8;
|
||||
$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task";
|
||||
$sql.= " WHERE ref like '".$this->prefix."____-%'";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) $max = intval($obj->max);
|
||||
else $max=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("mod_task_simple::getNextValue sql=".$sql);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$date=empty($task->date_c)?dol_now():$task->date_c;
|
||||
|
||||
//$yymm = strftime("%y%m",time());
|
||||
$yymm = strftime("%y%m",$date);
|
||||
$num = sprintf("%04s",$max+1);
|
||||
|
||||
dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
|
||||
return $this->prefix.$yymm."-".$num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return next reference not yet used as a reference
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Task $task Object task
|
||||
* @return string Next not used reference
|
||||
*/
|
||||
function task_get_num($objsoc=0,$task='')
|
||||
{
|
||||
return $this->getNextValue($objsoc,$task);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
142
htdocs/core/modules/project/task/mod_task_universal.php
Normal file
142
htdocs/core/modules/project/task/mod_task_universal.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/project/mod_project_universal.php
|
||||
* \ingroup project
|
||||
* \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
|
||||
|
||||
|
||||
/**
|
||||
* Classe du modele de numerotation de reference de projet Universal
|
||||
*/
|
||||
class mod_task_universal extends ModeleNumRefTask
|
||||
{
|
||||
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
|
||||
var $error = '';
|
||||
var $nom = 'Universal';
|
||||
|
||||
|
||||
/**
|
||||
* Renvoi la description du modele de numerotation
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
function info()
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("admin");
|
||||
|
||||
$form = new Form($this->db);
|
||||
|
||||
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
|
||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$texte.= '<input type="hidden" name="action" value="updateMaskTask">';
|
||||
$texte.= '<input type="hidden" name="maskconsttask" value="PROJECT_TASK_UNIVERSAL_MASK">';
|
||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
|
||||
$tooltip.=$langs->trans("GenericMaskCodes2");
|
||||
$tooltip.=$langs->trans("GenericMaskCodes3");
|
||||
$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Task"),$langs->transnoentities("Task"));
|
||||
$tooltip.=$langs->trans("GenericMaskCodes5");
|
||||
|
||||
// Parametrage du prefix
|
||||
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
|
||||
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="masktask" value="'.$conf->global->PROJECT_TASK_UNIVERSAL_MASK.'">',$tooltip,1,1).'</td>';
|
||||
|
||||
$texte.= '<td align="left" rowspan="2"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
|
||||
|
||||
$texte.= '</tr>';
|
||||
|
||||
$texte.= '</table>';
|
||||
$texte.= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi un exemple de numerotation
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
global $conf,$langs,$mysoc;
|
||||
|
||||
$old_code_client=$mysoc->code_client;
|
||||
$mysoc->code_client='CCCCCCCCCC';
|
||||
$numExample = $this->getNextValue($mysoc,'');
|
||||
$mysoc->code_client=$old_code_client;
|
||||
|
||||
if (! $numExample)
|
||||
{
|
||||
$numExample = $langs->trans('NotConfigured');
|
||||
}
|
||||
return $numExample;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return next value
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Project $project Object project
|
||||
* @return string Value if OK, 0 if KO
|
||||
*/
|
||||
function getNextValue($objsoc,$project)
|
||||
{
|
||||
global $db,$conf;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
|
||||
|
||||
// On defini critere recherche compteur
|
||||
$mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK;
|
||||
|
||||
if (! $mask)
|
||||
{
|
||||
$this->error='NotConfigured';
|
||||
return 0;
|
||||
}
|
||||
|
||||
$date=empty($project->date_c)?dol_now():$project->date_c;
|
||||
$numFinal=get_next_value($db,$mask,'projet_task','ref','',$objsoc->code_client,$date);
|
||||
|
||||
return $numFinal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return next reference not yet used as a reference
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Project $project Object project
|
||||
* @return string Next not used reference
|
||||
*/
|
||||
function project_get_num($objsoc=0,$project='')
|
||||
{
|
||||
return $this->getNextValue($objsoc,$project);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
252
htdocs/core/modules/project/task/modules_task.php
Normal file
252
htdocs/core/modules/project/task/modules_task.php
Normal file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010 Florian Henry <florian.henry<àopen-concept.pro>
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/project/task/modules_task.php
|
||||
* \ingroup project
|
||||
* \brief File that contain parent class for task models
|
||||
* and parent class for task numbering models
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Parent class for projects models
|
||||
*/
|
||||
abstract class ModelePDFTask extends CommonDocGenerator
|
||||
{
|
||||
var $error='';
|
||||
|
||||
|
||||
/**
|
||||
* Return list of active generation modules
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param string $maxfilenamelength Max length of value to show
|
||||
* @return array List of templates
|
||||
*/
|
||||
static function liste_modeles($db,$maxfilenamelength=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$type='project_task';
|
||||
$liste=array();
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
$liste=getListOfModels($db,$type,$maxfilenamelength);
|
||||
|
||||
return $liste;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Classe mere des modeles de numerotation des references de projets
|
||||
*/
|
||||
abstract class ModeleNumRefTask
|
||||
{
|
||||
var $error='';
|
||||
|
||||
/**
|
||||
* Return if a module can be used or not
|
||||
*
|
||||
* @return boolean true if module can be used
|
||||
*/
|
||||
function isEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi la description par defaut du modele de numerotation
|
||||
*
|
||||
* @return string Texte descripif
|
||||
*/
|
||||
function info()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("projects");
|
||||
return $langs->trans("NoDescription");
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi un exemple de numerotation
|
||||
*
|
||||
* @return string Example
|
||||
*/
|
||||
function getExample()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("projects");
|
||||
return $langs->trans("NoExample");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
|
||||
* de conflits qui empechera cette numerotation de fonctionner.
|
||||
*
|
||||
* @return boolean false si conflit, true si ok
|
||||
*/
|
||||
function canBeActivated()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi prochaine valeur attribuee
|
||||
*
|
||||
* @param Societe $objsoc Object third party
|
||||
* @param Project $project Object project
|
||||
* @return string Valeur
|
||||
*/
|
||||
function getNextValue($objsoc, $project)
|
||||
{
|
||||
global $langs;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi version du module numerotation
|
||||
*
|
||||
* @return string Valeur
|
||||
*/
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
|
||||
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
|
||||
if ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
return $langs->trans("NotAvailable");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an intervention document on disk using template defined into PROJECT_TASK_ADDON_PDF
|
||||
*
|
||||
* @param DoliDB $db objet base de donnee
|
||||
* @param Object $object Object fichinter
|
||||
* @param string $modele force le modele a utiliser ('' par defaut)
|
||||
* @param Translate $outputlangs objet lang a utiliser pour traduction
|
||||
* @param int $hidedetails Hide details of lines
|
||||
* @param int $hidedesc Hide description
|
||||
* @param int $hideref Hide ref
|
||||
* @param HookManager $hookmanager Hook manager instance
|
||||
* @return int 0 if KO, 1 if OK
|
||||
*/
|
||||
function task_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
|
||||
{
|
||||
global $conf,$langs;
|
||||
$langs->load("projects");
|
||||
|
||||
$error=0;
|
||||
|
||||
$srctemplatepath='';
|
||||
|
||||
// Positionne modele sur le nom du modele de projet a utiliser
|
||||
if (! dol_strlen($modele))
|
||||
{
|
||||
if (! empty($conf->global->PROJECT_TASK_ADDON_PDF))
|
||||
{
|
||||
$modele = $conf->global->PROJECT_TASK_ADDON_PDF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$modele='baleine';
|
||||
}
|
||||
}
|
||||
|
||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||
$tmp=explode(':',$modele,2);
|
||||
if (! empty($tmp[1]))
|
||||
{
|
||||
$modele=$tmp[0];
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array('/');
|
||||
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
foreach(array('doc','pdf') as $prefix)
|
||||
{
|
||||
$file = $prefix."_".$modele.".modules.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
$file=dol_buildpath($reldir."core/modules/project/task/pdf/".$file,0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname=$prefix.'_'.$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($filefound) break;
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
if ($filefound)
|
||||
{
|
||||
require_once $file;
|
||||
|
||||
$obj = new $classname($db);
|
||||
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $hookmanager) > 0)
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
|
||||
// we delete preview files
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($object);
|
||||
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($object);
|
||||
|
||||
// Appel des triggers
|
||||
/*include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($db);
|
||||
$result=$interface->run_triggers('PROJECT_BUILDDOC',$object,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }*/
|
||||
// Fin appel triggers
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
dol_print_error($db,"task_pdf_create Error: ".$obj->error);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@ -0,0 +1,844 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@ope-concept.pro>
|
||||
*
|
||||
* 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
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/project/task/pdf/doc_generic_task_odt.modules.php
|
||||
* \ingroup project
|
||||
* \brief File of class to build ODT documents for third parties
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
|
||||
if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to build documents using ODF templates generator
|
||||
*/
|
||||
class doc_generic_task_odt extends ModelePDFTask
|
||||
{
|
||||
var $emetteur; // Objet societe qui emet
|
||||
|
||||
var $phpmin = array(5,2,0); // Minimum version of PHP required by module
|
||||
var $version = 'dolibarr';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
global $conf,$langs,$mysoc;
|
||||
|
||||
$langs->load("main");
|
||||
$langs->load("companies");
|
||||
|
||||
$this->db = $db;
|
||||
$this->name = "ODT templates";
|
||||
$this->description = $langs->trans("DocumentModelOdt");
|
||||
$this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
|
||||
|
||||
// Dimension page pour format A4
|
||||
$this->type = 'odt';
|
||||
$this->page_largeur = 0;
|
||||
$this->page_hauteur = 0;
|
||||
$this->format = array($this->page_largeur,$this->page_hauteur);
|
||||
$this->marge_gauche=0;
|
||||
$this->marge_droite=0;
|
||||
$this->marge_haute=0;
|
||||
$this->marge_basse=0;
|
||||
|
||||
$this->option_logo = 1; // Affiche logo
|
||||
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
|
||||
$this->option_modereg = 0; // Affiche mode reglement
|
||||
$this->option_condreg = 0; // Affiche conditions reglement
|
||||
$this->option_codeproduitservice = 0; // Affiche code produit-service
|
||||
$this->option_multilang = 0; // Dispo en plusieurs langues
|
||||
$this->option_escompte = 0; // Affiche si il y a eu escompte
|
||||
$this->option_credit_note = 0; // Support credit notes
|
||||
$this->option_freetext = 1; // Support add of a personalised text
|
||||
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
||||
|
||||
// Recupere emetteur
|
||||
$this->emetteur=$mysoc;
|
||||
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param Object $object Main object to use as data source
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Array of substitution
|
||||
*/
|
||||
function get_substitutionarray_object($object,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'object_id'=>$object->id,
|
||||
'object_ref'=>$object->ref,
|
||||
'object_title'=>$object->title,
|
||||
'object_description'=>$object->description,
|
||||
'object_date_creation'=>dol_print_date($object->date_c,'day'),
|
||||
'object_date_modification'=>dol_print_date($object->date_m,'day'),
|
||||
'object_date_start'=>dol_print_date($object->date_start,'day'),
|
||||
'object_date_end'=>dol_print_date($object->date_end,'day'),
|
||||
'object_note_private'=>$object->note_private,
|
||||
'object_note_public'=>$object->note_public,
|
||||
'object_public'=>$object->public,
|
||||
'object_statut'=>$object->getLibStatut()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $task Task Object
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_tasks($task,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'task_ref'=>$task->ref,
|
||||
'task_fk_project'=>$task->fk_project,
|
||||
'task_projectref'=>$task->projectref,
|
||||
'task_projectlabel'=>$task->projectlabel,
|
||||
'task_label'=>$task->label,
|
||||
'task_description'=>$task->description,
|
||||
'task_fk_parent'=>$task->fk_parent,
|
||||
'task_duration'=>$task->duration,
|
||||
'task_progress'=>$task->progress,
|
||||
'task_public'=>$task->public,
|
||||
'task_date_start'=>dol_print_date($task->date_start,'day'),
|
||||
'task_date_end'=>dol_print_date($task->date_end,'day'),
|
||||
'task_note_private'=>$task->note_private,
|
||||
'task_note_public'=>$task->note_public
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $contact Contact array
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_project_contacts($contact,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'projcontacts_id'=>$contact['id'],
|
||||
'projcontacts_rowid'=>$contact['rowid'],
|
||||
'projcontacts_role'=>$contact['libelle'],
|
||||
'projcontacts_lastname'=>$contact['lastname'],
|
||||
'projcontacts_firstname'=>$contact['firstname'],
|
||||
'projcontacts_fullcivname'=>$contact['fullname'],
|
||||
'projcontacts_socname'=>$contact['socname'],
|
||||
'projcontacts_email'=>$contact['email']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $file file array
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_project_file($file,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'projfile_name'=>$file['name'],
|
||||
'projfile_date'=>dol_print_date($file['date'],'day'),
|
||||
'projfile_size'=>$file['size']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $refdetail Reference array
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_project_reference($refdetail,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'projref_type'=>$refdetail['type'],
|
||||
'projref_ref'=>$refdetail['ref'],
|
||||
'projref_date'=>dol_print_date($refdetail['date'],'day'),
|
||||
'projref_socname'=>$refdetail['socname'],
|
||||
'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
|
||||
'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
|
||||
'projref_status'=>$refdetail['status']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $taskressource Reference array
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_tasksressource($taskressource,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
//dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
|
||||
return array(
|
||||
'taskressource_rowid'=>$taskressource['rowid'],
|
||||
'taskressource_role'=>$taskressource['libelle'],
|
||||
'taskressource_lastname'=>$taskressource['lastname'],
|
||||
'taskressource_firstname'=>$taskressource['firstname'],
|
||||
'taskressource_fullcivname'=>$taskressource['fullname'],
|
||||
'taskressource_socname'=>$taskressource['socname'],
|
||||
'taskressource_email'=>$taskressource['email']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param object $tasktime times object
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_taskstime($tasktime,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'tasktime_rowid'=>$tasktime['rowid'],
|
||||
'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
|
||||
'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
|
||||
'tasktime_note'=>$tasktime['note'],
|
||||
'tasktime_fk_user'=>$tasktime['fk_user'],
|
||||
'tasktime_user_name'=>$tasktime['name'],
|
||||
'tasktime_user_first'=>$tasktime['firstname'],
|
||||
'tasktime_fullcivname'=>$tasktime['fullcivname']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define array with couple substitution key => substitution value
|
||||
*
|
||||
* @param array $file file array
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @return array Return a substitution array
|
||||
*/
|
||||
function get_substitutionarray_task_file($file,$outputlangs)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
return array(
|
||||
'tasksfile_name'=>$file['name'],
|
||||
'tasksfile_date'=>dol_print_date($file['date'],'day'),
|
||||
'tasksfile_size'=>$file['size']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return description of a module
|
||||
*
|
||||
* @param Translate $langs Lang object to use for output
|
||||
* @return string Description
|
||||
*/
|
||||
function info($langs)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("errors");
|
||||
|
||||
$form = new Form($this->db);
|
||||
|
||||
$texte = $this->description.".<br>\n";
|
||||
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
$texte.= '<input type="hidden" name="action" value="setModuleOptionsTask">';
|
||||
$texte.= '<input type="hidden" name="param1" value="PROJECT_TASK_ADDON_PDF_ODT_PATH">';
|
||||
$texte.= '<table class="nobordernopadding" width="100%">';
|
||||
|
||||
// List of directories area
|
||||
$texte.= '<tr><td>';
|
||||
$texttitle=$langs->trans("ListOfDirectories");
|
||||
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)));
|
||||
$listoffiles=array();
|
||||
foreach($listofdir as $key=>$tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
|
||||
if (! $tmpdir) {
|
||||
unset($listofdir[$key]); continue;
|
||||
}
|
||||
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
|
||||
else
|
||||
{
|
||||
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.odt');
|
||||
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
|
||||
}
|
||||
}
|
||||
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
|
||||
// Add list of substitution keys
|
||||
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
|
||||
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
|
||||
|
||||
$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
|
||||
$texte.= '<table><tr><td>';
|
||||
$texte.= '<textarea class="flat" cols="60" name="value1">';
|
||||
$texte.=$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH;
|
||||
$texte.= '</textarea>';
|
||||
$texte.= '</td>';
|
||||
$texte.= '<td align="center"> ';
|
||||
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
|
||||
$texte.= '</td>';
|
||||
$texte.= '</tr>';
|
||||
$texte.= '</table>';
|
||||
|
||||
// Scan directories
|
||||
if (count($listofdir)) $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
|
||||
|
||||
$texte.= '</td>';
|
||||
|
||||
|
||||
$texte.= '<td valign="top" rowspan="2">';
|
||||
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
|
||||
$texte.= '</td>';
|
||||
$texte.= '</tr>';
|
||||
|
||||
/*$texte.= '<tr>';
|
||||
$texte.= '<td align="center">';
|
||||
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
|
||||
$texte.= '</td>';
|
||||
$texte.= '</tr>';*/
|
||||
|
||||
$texte.= '</table>';
|
||||
$texte.= '</form>';
|
||||
|
||||
return $texte;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to build a document on disk using the generic odt module.
|
||||
*
|
||||
* @param Commande $object Object source to build document
|
||||
* @param Translate $outputlangs Lang output object
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||
* @return int 1 if OK, <=0 if KO
|
||||
*/
|
||||
function write_file($object,$outputlangs,$srctemplatepath)
|
||||
{
|
||||
global $user,$langs,$conf,$mysoc;
|
||||
|
||||
if (empty($srctemplatepath))
|
||||
{
|
||||
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (! is_object($outputlangs)) $outputlangs=$langs;
|
||||
$sav_charset_output=$outputlangs->charset_output;
|
||||
$outputlangs->charset_output='UTF-8';
|
||||
|
||||
$outputlangs->load("main");
|
||||
$outputlangs->load("dict");
|
||||
$outputlangs->load("companies");
|
||||
$outputlangs->load("projects");
|
||||
|
||||
if ($conf->projet->dir_output)
|
||||
{
|
||||
// If $object is id instead of object
|
||||
if (! is_object($object))
|
||||
{
|
||||
$id = $object;
|
||||
$object = new Task($this->db);
|
||||
$result=$object->fetch($id);
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error($this->db,$object->error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
$project= new Project($this->db);
|
||||
$project->fetch($object->fk_project);
|
||||
|
||||
$dir = $conf->projet->dir_output. "/" . $project->ref. "/";;
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
|
||||
$file = $dir . "/" . $objectref . ".odt";
|
||||
|
||||
if (! file_exists($dir))
|
||||
{
|
||||
print '$dir'.$dir;
|
||||
if (dol_mkdir($dir) < 0)
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($dir))
|
||||
{
|
||||
//print "srctemplatepath=".$srctemplatepath; // Src filename
|
||||
$newfile=basename($srctemplatepath);
|
||||
$newfiletmp=preg_replace('/\.odt/i','',$newfile);
|
||||
$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
|
||||
$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
|
||||
$newfiletmp=$objectref.'_'.$newfiletmp;
|
||||
//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
|
||||
$file=$dir.'/'.$newfiletmp.'.odt';
|
||||
//print "newdir=".$dir;
|
||||
//print "newfile=".$newfile;
|
||||
//print "file=".$file;
|
||||
//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
|
||||
|
||||
dol_mkdir($conf->projet->dir_temp);
|
||||
|
||||
$socobject=$object->thirdparty;
|
||||
|
||||
// Make substitution
|
||||
$substitutionarray=array(
|
||||
'__FROM_NAME__' => $this->emetteur->nom,
|
||||
'__FROM_EMAIL__' => $this->emetteur->email,
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $object);
|
||||
|
||||
// Open and load template
|
||||
require_once ODTPHP_PATH.'odf.php';
|
||||
$odfHandler = new odf(
|
||||
$srctemplatepath,
|
||||
array(
|
||||
'PATH_TO_TMP' => $conf->projet->dir_temp,
|
||||
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
|
||||
'DELIMITER_LEFT' => '{',
|
||||
'DELIMITER_RIGHT' => '}'
|
||||
)
|
||||
);
|
||||
// After construction $odfHandler->contentXml contains content and
|
||||
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
|
||||
// [!-- BEGIN lines --]*[!-- END lines --]
|
||||
//print html_entity_decode($odfHandler->__toString());
|
||||
//print exit;
|
||||
|
||||
|
||||
|
||||
|
||||
// Make substitutions into odt of user info
|
||||
$tmparray=$this->get_substitutionarray_user($user,$outputlangs);
|
||||
//var_dump($tmparray); exit;
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/',$key)) // Image
|
||||
{
|
||||
//var_dump($value);exit;
|
||||
if (file_exists($value)) $odfHandler->setImage($key, $value);
|
||||
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
else // Text
|
||||
{
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
// Make substitutions into odt of mysoc
|
||||
$tmparray=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
|
||||
//var_dump($tmparray); exit;
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/',$key)) // Image
|
||||
{
|
||||
//var_dump($value);exit;
|
||||
if (file_exists($value)) $odfHandler->setImage($key, $value);
|
||||
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
else // Text
|
||||
{
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Make substitutions into odt of thirdparty
|
||||
$tmparray=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/',$key)) // Image
|
||||
{
|
||||
if (file_exists($value)) $odfHandler->setImage($key, $value);
|
||||
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
else // Text
|
||||
{
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
$odfHandler->setVarsHeadFooter($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Replace tags of object + external modules
|
||||
$tmparray=$this->get_substitutionarray_object($project,$outputlangs);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||
foreach($tmparray as $key=>$value)
|
||||
{
|
||||
try {
|
||||
if (preg_match('/logo$/',$key)) // Image
|
||||
{
|
||||
if (file_exists($value)) $odfHandler->setImage($key, $value);
|
||||
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
|
||||
}
|
||||
else // Text
|
||||
{
|
||||
$odfHandler->setVars($key, $value, true, 'UTF-8');
|
||||
}
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Replace tags of lines for tasks
|
||||
try
|
||||
{
|
||||
// Security check
|
||||
$socid=0;
|
||||
if (!empty($project->fk_soc)) $socid = $project->fk_soc;
|
||||
|
||||
$tmparray=$this->get_substitutionarray_tasks($object,$outputlangs);
|
||||
complete_substitutions_array($tmparray, $outputlangs, $task);
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$odfHandler->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Replace tags of lines for contacts task
|
||||
$sourcearray=array('internal','external');
|
||||
$contact_arrray=array();
|
||||
foreach ($sourcearray as $source) {
|
||||
$contact_temp=$object->liste_contact(-1,$source);
|
||||
if ((is_array($contact_temp) && count($contact_temp) > 0))
|
||||
{
|
||||
$contact_arrray=array_merge($contact_arrray,$contact_temp);
|
||||
}
|
||||
}
|
||||
if ((is_array($contact_arrray) && count($contact_arrray) > 0))
|
||||
{
|
||||
$listlinestaskres = $odfHandler->setSegment('tasksressources');
|
||||
|
||||
foreach ($contact_arrray as $contact)
|
||||
{
|
||||
if ($contact['source']=='internal') {
|
||||
$objectdetail=new User($this->db);
|
||||
$objectdetail->fetch($contact['id']);
|
||||
$contact['socname']=$mysoc->name;
|
||||
} elseif ($contact['source']=='external') {
|
||||
$objectdetail=new Contact($this->db);
|
||||
$objectdetail->fetch($contact['id']);
|
||||
|
||||
$soc=new Societe($this->db);
|
||||
$soc->fetch($contact['socid']);
|
||||
$contact['socname']=$soc->name;
|
||||
}
|
||||
$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
|
||||
|
||||
$tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
|
||||
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlinestaskres->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listlinestaskres->merge();
|
||||
}
|
||||
$odfHandler->mergeSegment($listlinestaskres);
|
||||
}
|
||||
|
||||
//Time ressources
|
||||
$sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
|
||||
$sql.= ", u.name, u.firstname";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE t.fk_task =".$object->id;
|
||||
$sql .= " AND t.fk_user = u.rowid";
|
||||
$sql .= " ORDER BY t.task_date DESC";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
$tasks = array();
|
||||
$listlinestasktime = $odfHandler->setSegment('taskstimes');
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $this->db->fetch_array($resql);
|
||||
if (!empty($row['fk_user'])) {
|
||||
$objectdetail=new User($this->db);
|
||||
$objectdetail->fetch($row['fk_user']);
|
||||
$row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
|
||||
} else {
|
||||
$row['fullcivname']='';
|
||||
}
|
||||
|
||||
$tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
|
||||
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlinestasktime->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listlinestasktime->merge();
|
||||
$i++;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
$odfHandler->mergeSegment($listlinestasktime);
|
||||
}
|
||||
|
||||
|
||||
// Replace tags of project files
|
||||
$listtasksfiles = $odfHandler->setSegment('tasksfiles');
|
||||
|
||||
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref);
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$','name',SORT_ASC,1);
|
||||
|
||||
|
||||
foreach ($filearray as $filedetail)
|
||||
{
|
||||
$tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
|
||||
//dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listtasksfiles->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listtasksfiles->merge();
|
||||
}
|
||||
//$listlines->merge();
|
||||
|
||||
$odfHandler->mergeSegment($listtasksfiles);
|
||||
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
$this->error=$e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Replace tags of project files
|
||||
try
|
||||
{
|
||||
$listlines = $odfHandler->setSegment('projectfiles');
|
||||
|
||||
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$','name',SORT_ASC,1);
|
||||
|
||||
|
||||
foreach ($filearray as $filedetail)
|
||||
{
|
||||
//dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
|
||||
$tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
|
||||
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
$this->error=$e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Replace tags of lines for contacts
|
||||
$sourcearray=array('internal','external');
|
||||
$contact_arrray=array();
|
||||
foreach ($sourcearray as $source) {
|
||||
$contact_temp=$project->liste_contact(-1,$source);
|
||||
if ((is_array($contact_temp) && count($contact_temp) > 0))
|
||||
{
|
||||
$contact_arrray=array_merge($contact_arrray,$contact_temp);
|
||||
}
|
||||
}
|
||||
if ((is_array($contact_arrray) && count($contact_arrray) > 0))
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlines = $odfHandler->setSegment('projectcontacts');
|
||||
|
||||
foreach ($contact_arrray as $contact)
|
||||
{
|
||||
if ($contact['source']=='internal') {
|
||||
$objectdetail=new User($this->db);
|
||||
$objectdetail->fetch($contact['id']);
|
||||
$contact['socname']=$mysoc->name;
|
||||
} elseif ($contact['source']=='external') {
|
||||
$objectdetail=new Contact($this->db);
|
||||
$objectdetail->fetch($contact['id']);
|
||||
|
||||
$soc=new Societe($this->db);
|
||||
$soc->fetch($contact['socid']);
|
||||
$contact['socname']=$soc->name;
|
||||
}
|
||||
$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
|
||||
|
||||
$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
|
||||
|
||||
foreach($tmparray as $key => $val)
|
||||
{
|
||||
try
|
||||
{
|
||||
$listlines->setVars($key, $val, true, 'UTF-8');
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
}
|
||||
catch(SegmentException $e)
|
||||
{
|
||||
}
|
||||
}
|
||||
$listlines->merge();
|
||||
}
|
||||
$odfHandler->mergeSegment($listlines);
|
||||
}
|
||||
catch(OdfException $e)
|
||||
{
|
||||
$this->error=$e->getMessage();
|
||||
dol_syslog($this->error, LOG_WARNING);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write new file
|
||||
$odfHandler->saveToDisk($file);
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
BIN
htdocs/install/doctemplates/tasks/template_task_summary.odt
Normal file
BIN
htdocs/install/doctemplates/tasks/template_task_summary.odt
Normal file
Binary file not shown.
@ -402,7 +402,7 @@ if (! $error && $db->connected && $action == "set")
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$srcroot=$main_dir.'/install/doctemplates';
|
||||
$destroot=$main_data_dir.'/doctemplates';
|
||||
$docs=array('thirdparties' => 'thirdparty', 'proposals' => 'proposal', 'orders' => 'order', 'invoices' => 'invoice', 'projects' => 'project', 'projects' => 'task_summary');
|
||||
$docs=array('thirdparties' => 'thirdparty', 'proposals' => 'proposal', 'orders' => 'order', 'invoices' => 'invoice', 'projects' => 'project', 'projects' => 'task_summary', 'tasks' => 'task_summary');
|
||||
foreach($docs as $cursordir => $cursorfile)
|
||||
{
|
||||
$src=$srcroot.'/'.$cursordir.'/template_'.$cursorfile.'.odt';
|
||||
|
||||
@ -75,3 +75,27 @@ ALTER TABLE llx_cronjob ADD libname VARCHAR(255);
|
||||
|
||||
INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (30,'PROJECT_CREATE','Project creation','Executed when a project is created','project',30);
|
||||
|
||||
create table llx_categorie_contact
|
||||
(
|
||||
fk_categorie integer NOT NULL,
|
||||
fk_socpeople integer NOT NULL,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
|
||||
|
||||
ALTER TABLE llx_categorie_contact ADD PRIMARY KEY pk_categorie_contact (fk_categorie, fk_socpeople);
|
||||
ALTER TABLE llx_categorie_contact ADD INDEX idx_categorie_contact_fk_categorie (fk_categorie);
|
||||
ALTER TABLE llx_categorie_contact ADD INDEX idx_categorie_contact_fk_socpeople (fk_socpeople);
|
||||
|
||||
ALTER TABLE llx_categorie_contact ADD CONSTRAINT fk_categorie_contact_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
|
||||
ALTER TABLE llx_categorie_contact ADD CONSTRAINT fk_categorie_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople (rowid);
|
||||
|
||||
insert into llx_const (name, value, type, note, visible, entity) values ('PROJECT_TASK_ADDON_PDF','','chaine','Name of PDF/ODT tasks manager class',0,1);
|
||||
insert into llx_const (name, value, type, note, visible, entity) values ('PROJECT_TASK_ADDON','mod_task_simple','chaine','Name of Numbering Rule task manager class',0,1);
|
||||
insert into llx_const (name, value, type, note, visible, entity) values ('PROJECT_TASK_ADDON_PDF_ODT_PATH','DOL_DATA_ROOT/doctemplates/tasks','chaine','',0,1);
|
||||
|
||||
ALTER TABLE llx_projet_task ADD COLUMN ref varchar(50) AFTER rowid;
|
||||
UPDATE llx_projet_task SET ref=rowid;
|
||||
ALTER TABLE llx_projet_task ADD COLUMN model_pdf varchar(255);
|
||||
|
||||
|
||||
|
||||
24
htdocs/install/mysql/tables/llx_categorie_contact.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_categorie_contact.key.sql
Normal file
@ -0,0 +1,24 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2013 Florian HENRY <florian.henry@open-concept.pro>
|
||||
--
|
||||
-- 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
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- ============================================================================
|
||||
|
||||
ALTER TABLE llx_categorie_contact ADD PRIMARY KEY pk_categorie_contact (fk_categorie, fk_socpeople);
|
||||
ALTER TABLE llx_categorie_contact ADD INDEX idx_categorie_contact_fk_categorie (fk_categorie);
|
||||
ALTER TABLE llx_categorie_contact ADD INDEX idx_categorie_contact_fk_socpeople (fk_socpeople);
|
||||
|
||||
ALTER TABLE llx_categorie_contact ADD CONSTRAINT fk_categorie_contact_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
|
||||
ALTER TABLE llx_categorie_contact ADD CONSTRAINT fk_categorie_contact_fk_socpeople FOREIGN KEY (fk_socpeople) REFERENCES llx_socpeople (rowid);
|
||||
24
htdocs/install/mysql/tables/llx_categorie_contact.sql
Normal file
24
htdocs/install/mysql/tables/llx_categorie_contact.sql
Normal file
@ -0,0 +1,24 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2013 Florian HENRY <florian.henry@open-concept.pro>
|
||||
--
|
||||
-- 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
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- ============================================================================
|
||||
|
||||
create table llx_categorie_contact
|
||||
(
|
||||
fk_categorie integer NOT NULL,
|
||||
fk_socpeople integer NOT NULL,
|
||||
import_key varchar(14)
|
||||
)ENGINE=innodb;
|
||||
@ -29,8 +29,8 @@ create table llx_projet_task
|
||||
datev datetime, -- date validation
|
||||
label varchar(255) NOT NULL,
|
||||
description text,
|
||||
duration_effective real DEFAULT 0 NOT NULL,
|
||||
planned_workload real DEFAULT 0 NOT NULL,
|
||||
duration_effective real DEFAULT 0 NOT NULL,
|
||||
planned_workload real DEFAULT 0 NOT NULL,
|
||||
progress integer DEFAULT 0, -- percentage increase
|
||||
priority integer DEFAULT 0, -- priority
|
||||
fk_user_creat integer, -- user who created the task
|
||||
@ -38,5 +38,6 @@ create table llx_projet_task
|
||||
fk_statut smallint DEFAULT 0 NOT NULL,
|
||||
note_private text,
|
||||
note_public text,
|
||||
rang integer DEFAULT 0
|
||||
rang integer DEFAULT 0,
|
||||
model_pdf varchar(255)
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -1454,6 +1454,8 @@ TestGeoIPResult=Test of a conversion IP -> country
|
||||
ProjectsNumberingModules=Projects numbering module
|
||||
ProjectsSetup=Project module setup
|
||||
ProjectsModelModule=Project reports document model
|
||||
TasksNumberingModules=Tasks numbering module
|
||||
TaskModelModule=Tasks reports document model
|
||||
##### ECM (GED) #####
|
||||
ECMSetup = GED Setup
|
||||
ECMAutoTree = Automatic tree folder and document
|
||||
|
||||
@ -50,10 +50,12 @@ SupplierIsInCategories=Third party owns to following suppliers categories
|
||||
CompanyIsInCustomersCategories=This third party owns to following customers/prospects categories
|
||||
CompanyIsInSuppliersCategories=This third party owns to following suppliers categories
|
||||
MemberIsInCategories=This member owns to following members categories
|
||||
ContactIsInCategories=This contact owns to following contacts categories
|
||||
ProductHasNoCategory=This product/service is not in any categories
|
||||
SupplierHasNoCategory=This supplier is not in any categories
|
||||
CompanyHasNoCategory=This company is not in any categories
|
||||
MemberHasNoCategory=This member is not in any categories
|
||||
ContactHasNoCategory=This contact is not in any categories
|
||||
ClassifyInCategory=Classify in category
|
||||
NoneCategory=None
|
||||
NotCategorized=Without category
|
||||
@ -79,6 +81,7 @@ CustomersCategoriesShort=Customers categories
|
||||
CustomersProspectsCategoriesShort=Custo./Prosp. categories
|
||||
ProductsCategoriesShort=Products categories
|
||||
MembersCategoriesShort=Members categories
|
||||
ContactCategoriesShort=Contacts categories
|
||||
ThisCategoryHasNoProduct=This category does not contain any product.
|
||||
ThisCategoryHasNoSupplier=This category does not contain any supplier.
|
||||
ThisCategoryHasNoCustomer=This category does not contain any customer.
|
||||
@ -92,6 +95,7 @@ CatSupList=List of supplier categories
|
||||
CatCusList=List of customer/prospect categories
|
||||
CatProdList=List of products categories
|
||||
CatMemberList=List of members categories
|
||||
CatContactList=List of contact categories and contact
|
||||
CatSupLinks=Links between suppliers and categories
|
||||
CatCusLinks=Links between customers/prospects and categories
|
||||
CatProdLinks=Links between products/services and categories
|
||||
|
||||
@ -90,6 +90,7 @@ MailingModuleDescEmailsFromUser=EMails from user input (email;lastname;firstname
|
||||
MailingModuleDescContactsCategories=Third parties (by category)
|
||||
MailingModuleDescDolibarrContractsLinesExpired=Third parties with expired contract's lines
|
||||
MailingModuleDescContactsByCompanyCategory=Contacts/addresses of third parties (by third parties category)
|
||||
MailingModuleDescContactsByCategory=Contacts/addresses of third parties by category
|
||||
MailingModuleDescMembersCategories=Foundation members (by categories)
|
||||
MailingModuleDescContactsByFunction=Contacts/addresses of third parties (by position/function)
|
||||
|
||||
|
||||
@ -1454,6 +1454,8 @@ TestGeoIPResult=Test de conversion IP -> Pays
|
||||
ProjectsNumberingModules=Modèles de numérotation des références projets
|
||||
ProjectsSetup=Configuration du module Projets
|
||||
ProjectsModelModule=Modèles de document de rapport projets
|
||||
TasksNumberingModules==Modèles de numérotation des références taches
|
||||
TaskModelModule=Modèles de document de rapport taches
|
||||
##### ECM (GED) #####
|
||||
ECMSetup = Configuration du module GED
|
||||
ECMAutoTree = L'arborescence automatique est disponible
|
||||
|
||||
@ -50,10 +50,12 @@ SupplierIsInCategories=Ce fournisseur est dans les catégories suivantes
|
||||
CompanyIsInCustomersCategories=Cette société est dans les catégories clients/prospects suivantes
|
||||
CompanyIsInSuppliersCategories=Cette société est dans les catégories fournisseurs suivantes
|
||||
MemberIsInCategories=Cet adhérent est dans les catégories adhérent suivantes
|
||||
ContactIsInCategories=Ce contact est dans les catégories contact suivantes
|
||||
ProductHasNoCategory=Ce produit/service n'est dans aucune catégorie en particulier
|
||||
SupplierHasNoCategory=Ce fournisseur n'est dans aucune catégorie en particulier
|
||||
CompanyHasNoCategory=Cette société n'est dans aucune catégorie en particulier
|
||||
MemberHasNoCategory=Cet adhérent n'est dans aucune catégorie en particulier
|
||||
ContactHasNoCategory=Ce contact n'est dans aucune catégorie en particulier
|
||||
ClassifyInCategory=Classer dans la catégorie
|
||||
NoneCategory=Aucune
|
||||
NotCategorized=Sans catégorie
|
||||
@ -74,6 +76,7 @@ SuppliersCategoryShort=Catégorie fournisseurs
|
||||
CustomersCategoryShort=Catégorie clients
|
||||
ProductsCategoryShort=Catégorie produits
|
||||
MembersCategoryShort=Catégorie adhérent
|
||||
ContactCategoriesShort=Catégorie Contacts
|
||||
SuppliersCategoriesShort=Catégories fournisseurs
|
||||
CustomersCategoriesShort=Catégories clients
|
||||
CustomersProspectsCategoriesShort=Catégories clients/prospects
|
||||
@ -92,6 +95,7 @@ CatSupList=Liste des catégories fournisseurs
|
||||
CatCusList=Liste des catégories clients/prospects
|
||||
CatProdList=Liste des catégories produits
|
||||
CatMemberList=Liste des catégories adhérents
|
||||
CatContactList=Liste des catégories contacts et contacts
|
||||
CatSupLinks=Liens entre les fournisseurs et les catégories
|
||||
CatCusLinks=Liens entre les clients/prospects et les catégories
|
||||
CatProdLinks=Liens entre les produits/services et les catégories
|
||||
|
||||
@ -90,6 +90,7 @@ MailingModuleDescEmailsFromUser=Emails saisis manuellement (email;nom;prenom;aut
|
||||
MailingModuleDescContactsCategories=Tiers (par catégorie)
|
||||
MailingModuleDescDolibarrContractsLinesExpired=Tiers avec lignes de contrats de services expirées
|
||||
MailingModuleDescContactsByCompanyCategory=Contacts de tiers (par catégorie de tiers)
|
||||
MailingModuleDescContactsByCategory=Contacts de tiers par catégorie de contact
|
||||
MailingModuleDescMembersCategories=Adhérents (par catégorie)
|
||||
MailingModuleDescContactsByFunction=Contacts de tiers (par poste/fonction)
|
||||
|
||||
|
||||
@ -68,6 +68,25 @@ if ($action == 'updateMask')
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'updateMaskTask')
|
||||
{
|
||||
$maskconstmasktask=GETPOST('maskconsttask','alpha');
|
||||
$masktaskt=GETPOST('masktask','alpha');
|
||||
|
||||
if ($maskconstmasktask) $res = dolibarr_set_const($db,$maskconstmasktask,$masktaskt,'chaine',0,'',$conf->entity);
|
||||
|
||||
if (! $res > 0) $error++;
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'specimen')
|
||||
{
|
||||
$modele=GETPOST('module','alpha');
|
||||
@ -113,11 +132,61 @@ else if ($action == 'specimen')
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'specimentask')
|
||||
{
|
||||
$modele=GETPOST('module','alpha');
|
||||
|
||||
$project = new Project($db);
|
||||
$project->initAsSpecimen();
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
|
||||
foreach($dirmodels as $reldir)
|
||||
{
|
||||
$file=dol_buildpath($reldir."core/modules/project/task/pdf/pdf_".$modele.".modules.php",0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound=1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db);
|
||||
|
||||
if ($module->write_file($project,$langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project_task&file=SPECIMEN.pdf");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$obj->error.'</div>';
|
||||
dol_syslog($obj->error, LOG_ERR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
else if ($action == 'set')
|
||||
{
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
}
|
||||
// Activate a model for task
|
||||
else if ($action == 'settask')
|
||||
{
|
||||
$ret = addDocumentModel($value,'project_task', $label, $scandir);
|
||||
}
|
||||
|
||||
else if ($action == 'del')
|
||||
{
|
||||
@ -127,6 +196,14 @@ else if ($action == 'del')
|
||||
if ($conf->global->PROJECT_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_ADDON_PDF',$conf->entity);
|
||||
}
|
||||
}
|
||||
if ($action == 'deltask')
|
||||
{
|
||||
$ret = delDocumentModel($value, 'project_task');
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($conf->global->PROJECT_TASK_ADDON_PDF == "$value") dolibarr_del_const($db, 'PROJECT_TASK_ADDON_PDF',$conf->entity);
|
||||
}
|
||||
}
|
||||
|
||||
// Set default model
|
||||
else if ($action == 'setdoc')
|
||||
@ -146,6 +223,23 @@ else if ($action == 'setdoc')
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'setdoctask')
|
||||
{
|
||||
if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
|
||||
{
|
||||
// La constante qui a ete lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage coherent
|
||||
$conf->global->PROJECT_TASK_ADDON_PDF = $value;
|
||||
}
|
||||
|
||||
// On active le modele
|
||||
$ret = delDocumentModel($value, 'project_task');
|
||||
if ($ret > 0)
|
||||
{
|
||||
$ret = addDocumentModel($value, 'project_task', $label, $scandir);
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action == 'setmod')
|
||||
{
|
||||
// TODO Verifier si module numerotation choisi peut etre active
|
||||
@ -154,6 +248,14 @@ else if ($action == 'setmod')
|
||||
dolibarr_set_const($db, "PROJECT_ADDON",$value,'chaine',0,'',$conf->entity);
|
||||
}
|
||||
|
||||
else if ($action == 'setmodtask')
|
||||
{
|
||||
// TODO Verifier si module numerotation choisi peut etre active
|
||||
// par appel methode canBeActivated
|
||||
|
||||
dolibarr_set_const($db, "PROJECT_TASK_ADDON",$value,'chaine',0,'',$conf->entity);
|
||||
}
|
||||
|
||||
else if ($action=='setModuleOptions') {
|
||||
if (dolibarr_set_const($db, "PROJECT_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity))
|
||||
{
|
||||
@ -162,6 +264,15 @@ else if ($action=='setModuleOptions') {
|
||||
$conf->global->PROJECT_ADDON_PDF_ODT_PATH = GETPOST('value1');
|
||||
}
|
||||
}
|
||||
|
||||
else if ($action=='setModuleOptionsTask') {
|
||||
if (dolibarr_set_const($db, "PROJECT_TASK_ADDON_PDF_ODT_PATH",GETPOST('value1'),'chaine',0,'',$conf->entity))
|
||||
{
|
||||
// La constante qui a ete lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage coherent
|
||||
$conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH = GETPOST('value1');
|
||||
}
|
||||
}
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -285,6 +396,106 @@ foreach ($dirmodels as $reldir)
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
// Task numbering module
|
||||
print_titre($langs->trans("TasksNumberingModules"));
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="100">'.$langs->trans("Name").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td>'.$langs->trans("Example").'</td>';
|
||||
print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
|
||||
print '<td align="center" width="80">'.$langs->trans("Infos").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/project/task/");
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
$var=true;
|
||||
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
|
||||
{
|
||||
$file = $reg[1];
|
||||
$classname = substr($file,4);
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$file.'.php';
|
||||
|
||||
$module = new $file;
|
||||
|
||||
// Show modules according to features level
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
||||
|
||||
if ($module->isEnabled())
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
|
||||
print $module->info();
|
||||
print '</td>';
|
||||
|
||||
// Show example of numbering module
|
||||
print '<td nowrap="nowrap">';
|
||||
$tmp=$module->getExample();
|
||||
if (preg_match('/^Error/',$tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
|
||||
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
|
||||
else print $tmp;
|
||||
print '</td>'."\n";
|
||||
|
||||
print '<td align="center">';
|
||||
if ($conf->global->PROJECT_TASK_ADDON == 'mod_'.$classname)
|
||||
{
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodtask&value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
$project=new Project($db);
|
||||
$project->initAsSpecimen();
|
||||
|
||||
// Info
|
||||
$htmltooltip='';
|
||||
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
|
||||
$nextval=$module->getNextValue($mysoc,$project);
|
||||
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
|
||||
{
|
||||
$htmltooltip.=''.$langs->trans("NextValue").': ';
|
||||
if ($nextval)
|
||||
{
|
||||
$htmltooltip.=$nextval.'<br>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$htmltooltip.=$langs->trans($module->error).'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<td align="center">';
|
||||
print $form->textwithpicto('',$htmltooltip,1,0);
|
||||
print '</td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table><br>';
|
||||
|
||||
/*
|
||||
* Document templates generators
|
||||
@ -412,6 +623,143 @@ foreach ($dirmodels as $reldir)
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</table><br/>';
|
||||
|
||||
/*
|
||||
* Modeles documents for Task
|
||||
*/
|
||||
|
||||
print_titre($langs->trans("TaskModelModule"));
|
||||
|
||||
// Defini tableau def de modele
|
||||
$type='project_task';
|
||||
$def = array();
|
||||
|
||||
$sql = "SELECT nom";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$i = 0;
|
||||
$num_rows=$db->num_rows($resql);
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$array = $db->fetch_array($resql);
|
||||
array_push($def, $array[0]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">\n";
|
||||
print "<tr class=\"liste_titre\">\n";
|
||||
print ' <td width="100">'.$langs->trans("Name")."</td>\n";
|
||||
print " <td>".$langs->trans("Description")."</td>\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Activated")."</td>\n";
|
||||
print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
|
||||
print '<td align="center" width="80">'.$langs->trans("Infos").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
clearstatcache();
|
||||
|
||||
$var=true;
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/project/task/pdf/");
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle=opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
|
||||
{
|
||||
if (file_exists($dir.'/'.$file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) -16);
|
||||
$classname = substr($file, 0, dol_strlen($file) -12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db);
|
||||
|
||||
$modulequalified=1;
|
||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
|
||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
|
||||
|
||||
if ($modulequalified)
|
||||
{
|
||||
$var = !$var;
|
||||
print '<tr '.$bc[$var].'><td width="100">';
|
||||
print (empty($module->name)?$name:$module->name);
|
||||
print "</td><td>\n";
|
||||
if (method_exists($module,'info')) print $module->info($langs);
|
||||
else print $module->description;
|
||||
print "</td>\n";
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
print "<td align=\"center\">\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=deltask&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'">';
|
||||
print img_picto($langs->trans("Enabled"),'switch_on');
|
||||
print '</a>';
|
||||
print "</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<td align=\"center\">\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=settask&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Defaut
|
||||
print "<td align=\"center\">";
|
||||
if ($conf->global->PROJECT_TASK_ADDON_PDF == "$name")
|
||||
{
|
||||
print img_picto($langs->trans("Default"),'on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoctask&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
|
||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
|
||||
|
||||
// Preview
|
||||
print '<td align="center">';
|
||||
if ($module->type == 'pdf')
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimentask&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print img_object($langs->trans("PreviewNotAvailable"),'generic');
|
||||
}
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,6 +36,8 @@ class Task extends CommonObject
|
||||
|
||||
var $id;
|
||||
|
||||
var $ref;
|
||||
|
||||
var $fk_project;
|
||||
var $fk_task_parent;
|
||||
var $label;
|
||||
@ -52,6 +54,7 @@ class Task extends CommonObject
|
||||
var $statut;
|
||||
var $note_private;
|
||||
var $note_public;
|
||||
var $rang;
|
||||
|
||||
var $timespent_id;
|
||||
var $timespent_duration;
|
||||
@ -95,6 +98,7 @@ class Task extends CommonObject
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task (";
|
||||
$sql.= "fk_projet";
|
||||
$sql.= ", ref";
|
||||
$sql.= ", fk_task_parent";
|
||||
$sql.= ", label";
|
||||
$sql.= ", description";
|
||||
@ -106,6 +110,7 @@ class Task extends CommonObject
|
||||
$sql.= ", progress";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= $this->fk_project;
|
||||
$sql.= ", ".(!empty($this->ref)?"'".$this->db->escape($this->ref)."'":'null');
|
||||
$sql.= ", ".$this->fk_task_parent;
|
||||
$sql.= ", '".$this->db->escape($this->label)."'";
|
||||
$sql.= ", '".$this->db->escape($this->description)."'";
|
||||
@ -173,14 +178,16 @@ class Task extends CommonObject
|
||||
* Load object in memory from database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param int $ref ref object
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
function fetch($id,$ref='')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.ref,";
|
||||
$sql.= " t.fk_projet,";
|
||||
$sql.= " t.fk_task_parent,";
|
||||
$sql.= " t.label,";
|
||||
@ -196,9 +203,15 @@ class Task extends CommonObject
|
||||
$sql.= " t.progress,";
|
||||
$sql.= " t.priority,";
|
||||
$sql.= " t.note_private,";
|
||||
$sql.= " t.note_public";
|
||||
$sql.= " t.note_public,";
|
||||
$sql.= " t.rang";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as t";
|
||||
$sql.= " WHERE t.rowid = ".$id;
|
||||
$sql.= " WHERE ";
|
||||
if (!empty($ref)) {
|
||||
$sql.="t.ref = '".$ref."'";
|
||||
}else {
|
||||
$sql.="t.rowid = ".$id;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -209,7 +222,7 @@ class Task extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->fk_project = $obj->fk_projet;
|
||||
$this->fk_task_parent = $obj->fk_task_parent;
|
||||
$this->label = $obj->label;
|
||||
@ -226,6 +239,7 @@ class Task extends CommonObject
|
||||
$this->priority = $obj->priority;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->rang = $obj->rang;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
@ -255,6 +269,7 @@ class Task extends CommonObject
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project);
|
||||
if (isset($this->ref)) $this->ref=trim($this->ref);
|
||||
if (isset($this->fk_task_parent)) $this->fk_task_parent=trim($this->fk_task_parent);
|
||||
if (isset($this->label)) $this->label=trim($this->label);
|
||||
if (isset($this->description)) $this->description=trim($this->description);
|
||||
@ -267,6 +282,7 @@ class Task extends CommonObject
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET";
|
||||
$sql.= " fk_projet=".(isset($this->fk_project)?$this->fk_project:"null").",";
|
||||
$sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"'".$this->id."'").",";
|
||||
$sql.= " fk_task_parent=".(isset($this->fk_task_parent)?$this->fk_task_parent:"null").",";
|
||||
$sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
|
||||
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
||||
@ -274,7 +290,8 @@ class Task extends CommonObject
|
||||
$sql.= " planned_workload=".(isset($this->planned_workload)?$this->planned_workload:"0").",";
|
||||
$sql.= " dateo=".($this->date_start!=''?$this->db->idate($this->date_start):'null').",";
|
||||
$sql.= " datee=".($this->date_end!=''?$this->db->idate($this->date_end):'null').",";
|
||||
$sql.= " progress=".$this->progress;
|
||||
$sql.= " progress=".$this->progress.",";
|
||||
$sql.= " rang=".((!empty($this->rang))?$this->rang:"0");
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
@ -500,6 +517,7 @@ class Task extends CommonObject
|
||||
$this->id=0;
|
||||
|
||||
$this->fk_projet='';
|
||||
$this->ref='';
|
||||
$this->fk_task_parent='';
|
||||
$this->title='';
|
||||
$this->duration_effective='';
|
||||
@ -531,7 +549,7 @@ class Task extends CommonObject
|
||||
// List of tasks (does not care about permissions. Filtering will be done later)
|
||||
$sql = "SELECT p.rowid as projectid, p.ref, p.title as plabel, p.public,";
|
||||
$sql.= " t.rowid as taskid, t.label, t.description, t.fk_task_parent, t.duration_effective, t.progress,";
|
||||
$sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload";
|
||||
$sql.= " t.dateo as date_start, t.datee as date_end, t.planned_workload, t.ref as ref_task,t.rang";
|
||||
if ($mode == 0)
|
||||
{
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
|
||||
@ -583,9 +601,9 @@ class Task extends CommonObject
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$tasks[$i] = new stdClass();
|
||||
$tasks[$i] = new Task($db);
|
||||
$tasks[$i]->id = $obj->taskid;
|
||||
$tasks[$i]->ref = $obj->taskid;
|
||||
$tasks[$i]->ref = $obj->ref_task;
|
||||
$tasks[$i]->fk_project = $obj->projectid;
|
||||
$tasks[$i]->projectref = $obj->ref;
|
||||
$tasks[$i]->projectlabel = $obj->plabel;
|
||||
@ -598,6 +616,7 @@ class Task extends CommonObject
|
||||
$tasks[$i]->public = $obj->public;
|
||||
$tasks[$i]->date_start = $this->db->jdate($obj->date_start);
|
||||
$tasks[$i]->date_end = $this->db->jdate($obj->date_end);
|
||||
$tasks[$i]->rang = $obj->rang;
|
||||
}
|
||||
|
||||
$i++;
|
||||
@ -993,19 +1012,32 @@ class Task extends CommonObject
|
||||
$datec = $now;
|
||||
|
||||
$clone_task=new Task($this->db);
|
||||
$origin_task=new Task($this->db);
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$clone_task->fetch($fromid);
|
||||
$origin_task->fetch($fromid);
|
||||
|
||||
$defaultref='';
|
||||
$obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON;
|
||||
if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php"))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php';
|
||||
$modTask = new $obj;
|
||||
$defaultref = $modTask->getNextValue(0,$clone_task);
|
||||
}
|
||||
|
||||
$ori_project_id = $clone_task->fk_project;
|
||||
|
||||
$clone_task->id = 0;
|
||||
$clone_task->ref = $defaultref;
|
||||
$clone_task->fk_project = $project_id;
|
||||
$clone_task->fk_task_parent = $parent_task_id;
|
||||
$clone_task->date_c = $datec;
|
||||
$clone_task->planned_workload = $clone_task->planned_workload;
|
||||
$clone_task->rang = $origin_task->rang;
|
||||
|
||||
//Manage Task Date
|
||||
if ($clone_change_dt)
|
||||
|
||||
@ -114,6 +114,7 @@ if ($action == 'createtask' && $user->rights->projet->creer)
|
||||
$task = new Task($db);
|
||||
|
||||
$task->fk_project = $projectid;
|
||||
$task->ref = GETPOST('ref','alpha');
|
||||
$task->label = $label;
|
||||
$task->description = $description;
|
||||
$task->planned_workload = $planned_workload * 3600;//We set the planned workload into seconds
|
||||
@ -170,6 +171,7 @@ if ($action == 'createtask' && $user->rights->projet->creer)
|
||||
|
||||
$form=new Form($db);
|
||||
$formother=new FormOther($db);
|
||||
$taskstatic = new Task($db);
|
||||
$userstatic=new User($db);
|
||||
|
||||
$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos";
|
||||
@ -266,11 +268,27 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->socie
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="createtask">';
|
||||
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||
|
||||
if (! empty($object->id)) print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
if (! empty($mode)) print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$defaultref='';
|
||||
$obj = empty($conf->global->PROJECT_TASK_ADDON)?'mod_task_simple':$conf->global->PROJECT_TASK_ADDON;
|
||||
if (! empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.".php"))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/project/task/".$conf->global->PROJECT_TASK_ADDON.'.php';
|
||||
$modTask = new $obj;
|
||||
$defaultref = $modTask->getNextValue($soc,$object);
|
||||
}
|
||||
|
||||
if (is_numeric($defaultref) && $defaultref <= 0) $defaultref='';
|
||||
|
||||
// Ref
|
||||
print '<input type="hidden" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'">';
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td>'.($_POST["ref"]?$_POST["ref"]:$defaultref).'</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
|
||||
print '<input type="text" size="25" name="label" class="flat" value="'.$label.'">';
|
||||
print '</td></tr>';
|
||||
@ -394,7 +412,7 @@ else
|
||||
print '<table id="tablelines" class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
// print '<td>'.$langs->trans("Project").'</td>';
|
||||
print '<td width="80">'.$langs->trans("RefTask").'</td>';
|
||||
print '<td width="100">'.$langs->trans("RefTask").'</td>';
|
||||
print '<td>'.$langs->trans("LabelTask").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateStart").'</td>';
|
||||
print '<td align="center">'.$langs->trans("DateEnd").'</td>';
|
||||
|
||||
@ -23,6 +23,10 @@
|
||||
* \brief Page of a project task
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', true);
|
||||
ini_set('html_errors', false);
|
||||
|
||||
require ("../../main.inc.php");
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
@ -30,6 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("companies");
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$ref=GETPOST('ref','alpha');
|
||||
@ -68,7 +77,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$object->fetch($id,$ref);
|
||||
|
||||
$tmparray=explode('_',$_POST['task_parent']);
|
||||
$task_parent=$tmparray[1];
|
||||
@ -95,7 +104,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer)
|
||||
{
|
||||
if ($object->fetch($id) >= 0 )
|
||||
if ($object->fetch($id,$ref) >= 0 )
|
||||
{
|
||||
$result=$projectstatic->fetch($object->fk_projet);
|
||||
if (! empty($projectstatic->socid))
|
||||
@ -134,20 +143,67 @@ if (! empty($project_ref) && ! empty($withproject))
|
||||
}
|
||||
}
|
||||
|
||||
// Build doc
|
||||
if ($action == 'builddoc' && $user->rights->projet->creer)
|
||||
{
|
||||
if ($object->fetch($id,$ref) >= 0 )
|
||||
{
|
||||
if (GETPOST('model'))
|
||||
{
|
||||
$object->setDocModel($user, GETPOST('model'));
|
||||
}
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (GETPOST('lang_id'))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang(GETPOST('lang_id'));
|
||||
}
|
||||
$result=task_pdf_create($db, $object, $object->modelpdf, $outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete file in doc form
|
||||
if ($action == 'remove_file' && $user->rights->projet->creer)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
if ($object->fetch($id,$ref) >= 0 )
|
||||
{
|
||||
$langs->load("other");
|
||||
$upload_dir = $conf->projet->dir_output;
|
||||
$file = $upload_dir . '/' . GETPOST('file');
|
||||
|
||||
$ret=dol_delete_file($file);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$langs->load('projects');
|
||||
|
||||
llxHeader('', $langs->trans("Task"));
|
||||
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
if ($object->fetch($id) > 0)
|
||||
if ($object->fetch($id,$ref) > 0)
|
||||
{
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
@ -345,7 +401,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
|
||||
}
|
||||
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
|
||||
print $form->showrefnav($object,'id',$linkback,1,'rowid','ref','',$param);
|
||||
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','',$param);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -434,6 +490,26 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
$filename=dol_sanitizeFileName($projectstatic->ref). "/". dol_sanitizeFileName($object->ref);
|
||||
$filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($projectstatic->ref). "/" .dol_sanitizeFileName($object->ref);
|
||||
$urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed=($user->rights->projet->lire);
|
||||
$delallowed=($user->rights->projet->creer);
|
||||
|
||||
$var=true;
|
||||
|
||||
$somethingshown=$formfile->show_documents('project_task',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
|
||||
|
||||
|
||||
|
||||
print '</td></tr></table>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user