Workflow is empty by default but can be modified with module workflow

This commit is contained in:
Laurent Destailleur 2011-03-01 09:22:58 +00:00
parent 804e03330c
commit 56a5e4f9c1
3 changed files with 392 additions and 0 deletions

128
htdocs/admin/workflow.php Executable file
View File

@ -0,0 +1,128 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/admin/societe.php
* \ingroup company
* \brief Third party module setup page
* \version $Id$
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
$langs->load("admin");
if (!$user->admin)
accessforbidden();
/*
* Actions
*/
if (preg_match('/set(.*)/',$_GET["action"],$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
if (preg_match('/del(.*)/',$_GET["action"],$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
/*
* View
*/
$form=new Form($db);
llxHeader('',$langs->trans("WorkflowSetup"),'');
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans("WorkflowSetup"),$linkback,'setup');
print $langs->trans("WorkflowDesc").'<br>';
print "<br>";
// Choix du module de gestion des codes clients / fournisseurs
print "<table class=\"noborder\" width=\"100%\">\n";
print "<tr class=\"liste_titre\">\n";
print ' <td>'.$langs->trans("Description").'</td>';
print ' <td align="center">'.$langs->trans("Status").'</td>';
print ' <td align="center" width="60">'.$langs->trans("Infos").'</td>';
print "</tr>\n";
clearstatcache();
$workflowcodes=array('WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>'WORKFLOW_PROPAL_AUTOCREATE_ORDER');
foreach($workflowcodes as $code)
{
$var = !$var;
print "<tr ".$bc[$var].">\n";
print "<td>".$langs->trans($code)."</td>\n";
if (! empty($conf->global->$code))
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=del'.$code.'">';
print img_picto($langs->trans("Activated"),'on');
print '</a></td>';
}
else
{
print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=set'.$code.'">';
print img_picto($langs->trans("Disabled"),'off');
print '</a></td>';
}
print '<td align="center">';
//$s=$modCodeTiers->getToolTip($langs,$soc,-1);
//print $form->textwithpicto('',$s,1);
print '</td>';
print '</tr>';
}
print '</table>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -772,6 +772,91 @@ class Commande extends CommonObject
}
/**
* Load an object from a proposal and create a new order into database
* @param object Object source
* @param invertdetail Reverse sign of amounts for lines
* @return int <0 if KO, 0 if nothing done, 1 if OK
*/
function createFromProposal($object,$invertdetail=0)
{
global $conf,$user,$langs;
$error=0;
// Signed proposal
if ($object->statut == 2)
{
$this->date_commande = dol_now();
$this->source = 0;
for ($i = 0 ; $i < sizeof($object->lines) ; $i++)
{
$line = new OrderLine($this->db);
$line->libelle = $object->lines[$i]->libelle;
$line->desc = $object->lines[$i]->desc;
$line->price = $object->lines[$i]->price;
$line->subprice = $object->lines[$i]->subprice;
$line->tva_tx = $object->lines[$i]->tva_tx;
$line->localtax1_tx = $object->lines[$i]->localtax1_tx;
$line->localtax2_tx = $object->lines[$i]->localtax2_tx;
$line->qty = $object->lines[$i]->qty;
$line->fk_remise_except = $object->lines[$i]->fk_remise_except;
$line->remise_percent = $object->lines[$i]->remise_percent;
$line->fk_product = $object->lines[$i]->fk_product;
$line->info_bits = $object->lines[$i]->info_bits;
$line->product_type = $object->lines[$i]->product_type;
$line->special_code = $object->lines[$i]->special_code;
$this->lines[$i] = $line;
}
$this->socid = $object->socid;
$this->fk_project = $object->fk_project;
$this->cond_reglement_id = $object->cond_reglement_id;
$this->mode_reglement_id = $object->mode_reglement_id;
$this->date_livraison = $object->date_livraison;
$this->fk_delivery_address = $object->fk_delivery_address;
$this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client;
$this->note = $object->note;
$this->note_public = $object->note_public;
$this->origin = $object->element;
$this->origin_id = $object->id;
$ret = $this->create($user);
if ($ret > 0)
{
// Hooks
if (! empty($object->hooks))
{
foreach($object->hooks as $module)
{
$result = $module->createfrom($object,$ret,$this->element);
if ($result < 0) $error++;
}
}
if (! $error)
{
// Ne pas passer par la commande provisoire
if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
{
$this->fetch($ret);
$this->valid($user);
}
return 1;
}
else return -1;
}
}
else return 0;
}
/**
* Add an order line into database (linked to product/service or not)
* @param commandeid Id of line

View File

@ -0,0 +1,179 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \defgroup workflow Module workflow
* \brief Workflow management
* \version $Id$
*/
/**
* \file htdocs/includes/modules/modWorkflow.class.php
* \ingroup workflow
* \brief Fichier de description et activation du module Workflow
*/
include_once(DOL_DOCUMENT_ROOT ."/includes/modules/DolibarrModules.class.php");
/**
* \class modWorkflow
* \brief Classe de description et activation du module Workflow
*/
class modWorkflow extends DolibarrModules
{
/**
* \brief Constructeur. Definit les noms, constantes et boites
* \param DB handler d'acces base
*/
function modWorkflow($DB)
{
$this->db = $DB ;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 6000 ;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'workflow';
$this->family = "base";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Workflow management";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'experimental';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 2;
// Name of png file (without png) used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto='technic';
// Defined if the directory /mymodule/inc/triggers/ contains triggers or not
$this->triggers = 1;
// Data directories to create when module is enabled
$this->dirs = array("/workflow/temp");
// Relative path to module style sheet if exists. Example: '/mymodule/mycss.css'.
$this->style_sheet = '';
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
$this->config_page_url = 'workflow.php';
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(5,2); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(2,8); // Minimum version of Dolibarr required by module
$this->langfiles = array("@workflow");
// Constants
// List of particular constants to add when module is enabled
//Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0),
// 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) );
$this->const=array();
// Boxes
$this->boxes = array();
//$this->boxes[0][1] = "box_workflow@workflow";
// Permissions
$this->rights = array();
$r=0;
/*
$r++;
$this->rights[$r][0] = 6001; // id de la permission
$this->rights[$r][1] = "Lire les workflow"; // libelle de la permission
$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'read';
*/
// Main menu entries
$this->menus = array(); // List of menus to add
$r=0;
/*
$this->menu[$r]=array('fk_menu'=>0,
'type'=>'top',
'titre'=>'Workflow',
'mainmenu'=>'workflow',
'leftmenu'=>'1',
'url'=>'/workflow/index.php',
'langs'=>'@workflow',
'position'=>100,
'perms'=>'$user->rights->workflow->read',
'enabled'=>'$conf->workflow->enabled',
'target'=>'',
'user'=>0);
$r++;
$this->menu[$r]=array( 'fk_menu'=>'r=0',
'type'=>'left',
'titre'=>'Workflow',
'mainmenu'=>'workflow',
'url'=>'/workflow/index.php',
'langs'=>'@workflow',
'position'=>101,
'enabled'=>1,
'perms'=>'$user->rights->workflow->read',
'target'=>'',
'user'=>0);
$r++;
*/
}
/**
* \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module.
* Definit egalement les repertoires de donnees a creer pour ce module.
*/
function init()
{
//$result=$this->load_tables();
return $this->_init($sql);
}
/**
* \brief Fonction appelee lors de la desactivation d'un module.
* Supprime de la base les constantes, boites et permissions du module.
*/
function remove()
{
$sql = array();
return $this->_remove($sql);
}
/**
* \brief Create tables and keys required by module
* This function is called by this->init.
* \return int <=0 if KO, >0 if OK
*/
function load_tables()
{
return $this->_load_tables('/workflow/sql/');
}
}
?>