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

This commit is contained in:
Regis Houssin 2017-07-26 15:25:17 +02:00
commit 89a9049ccb
8 changed files with 201 additions and 113 deletions

View File

@ -42,7 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
*/
class Categorie extends CommonObject
{
// Categories types
// Categories types (we use string because we want to accept any modules/types in a future)
const TYPE_PRODUCT = 'product';
const TYPE_SUPPLIER = 'supplier';
const TYPE_CUSTOMER = 'customer';
@ -189,15 +189,16 @@ class Categorie extends CommonObject
*
* @param int $id Id of category
* @param string $label Label of category
* @param string $type Type of category
* @param string $type Type of category ('product', '...') or (0, 1, ...)
* @return int <0 if KO, >0 if OK
*/
function fetch($id,$label='',$type='')
function fetch($id, $label='', $type=null)
{
global $conf;
// Check parameters
if (empty($id) && empty($label)) return -1;
if (! is_numeric($type)) $type=$this->MAP_ID[$type];
$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
@ -208,7 +209,7 @@ class Categorie extends CommonObject
else
{
$sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
if ($type) $sql.= " AND type = '".$this->db->escape($type)."'";
if (! is_null($type)) $sql.= " AND type = ".$this->db->escape($type);
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@ -265,6 +266,10 @@ class Categorie extends CommonObject
global $conf,$langs,$hookmanager;
$langs->load('categories');
$type=$this->type;
if (! is_numeric($type)) $type=$this->MAP_ID[$type];
$error=0;
dol_syslog(get_class($this).'::create', LOG_DEBUG);
@ -310,7 +315,7 @@ class Categorie extends CommonObject
$sql.= ($this->socid != -1 ? $this->socid : 'null').",";
}
$sql.= "'".$this->visible."',";
$sql.= $this->type.",";
$sql.= $type.",";
$sql.= (! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":'null').",";
$sql.= $conf->entity;
$sql.= ")";
@ -629,12 +634,11 @@ class Categorie extends CommonObject
/**
* Link an object to the category
*
* @param CommonObject $obj Object to link to category
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
*
* @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
* @param CommonObject $obj Object to link to category
* @param string $type Type of category ('product', ...)
* @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
*/
function add_type($obj,$type)
function add_type($obj, $type)
{
global $user,$langs,$conf;
@ -851,13 +855,12 @@ class Categorie extends CommonObject
/**
* Check for the presence of an object in a category
*
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
* @param int $object_id id of the object to search
*
* @return int number of occurrences
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
* @param int $object_id Id of the object to search
* @return int Number of occurrences
* @see getObjectsInCateg
*/
function containsObject($type, $object_id )
function containsObject($type, $object_id)
{
$sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
$sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id;
@ -944,24 +947,16 @@ class Categorie extends CommonObject
* fulllabel = nom avec chemin complet de la categorie
* fullpath = chemin complet compose des id
*
* @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member').
* Old mode (0, 1, 2, ...) is deprecated.
* @param int $markafterid Removed all categories including the leaf $markafterid in category tree.
* @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...).
* @param int $markafterid Removed all categories including the leaf $markafterid in category tree.
*
* @return array Array of categories. this->cats and this->motherof are set.
* @return array Array of categories. this->cats and this->motherof are set.
*/
function get_full_arbo($type, $markafterid=0)
{
global $conf, $langs;
// For backward compatibility
if (is_numeric($type))
{
// We want to reverse lookup
$map_type = array_flip($this->MAP_ID);
$type = $map_type[$type];
dol_syslog( get_class( $this ) . "::get_full_arbo(): numeric types are deprecated, please use string instead", LOG_WARNING);
}
if (! is_numeric($type)) $type = $this->MAP_ID[$type];
$this->cats = array();
@ -975,7 +970,7 @@ class Categorie extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
$sql .= " WHERE c.entity IN (" . getEntity( 'category', 1 ) . ")";
$sql .= " AND c.type = " . $this->MAP_ID[$type];
$sql .= " AND c.type = " . $type;
dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -1099,7 +1094,7 @@ class Categorie extends CommonObject
/**
* Returns all categories
*
* @param int $type Type of category
* @param int $type Type of category (0, 1, ...)
* @param boolean $parent Just parent categories if true
* @return array Table of Object Category
*/
@ -1162,13 +1157,17 @@ class Categorie extends CommonObject
*/
function already_exists()
{
$type=$this->type;
if (! is_numeric($type)) $type=$this->MAP_ID[$type];
/* We have to select any rowid from llx_categorie which category's mother and label
* are equals to those of the calling category
*/
$sql = "SELECT c.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c ";
$sql.= " WHERE c.entity IN (".getEntity('category').")";
$sql.= " AND c.type = ".$this->type;
$sql.= " AND c.type = ".$type;
$sql.= " AND c.fk_parent = ".$this->fk_parent;
$sql.= " AND c.label = '".$this->db->escape($this->label)."'";
@ -1203,7 +1202,7 @@ class Categorie extends CommonObject
/**
* Returns the top level categories (which are not girls)
*
* @param int $type Type of category
* @param int $type Type of category (0, 1, ...)
* @return array
*/
function get_main_categories($type=null)
@ -1341,24 +1340,17 @@ class Categorie extends CommonObject
* Return list of categories (object instances or labels) linked to element of id $id and type $type
* Should be named getListOfCategForObject
*
* @param int $id Id of element
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated.
* @param string $mode 'id'=Get array of category ids, 'object'=Get array of fetched category instances, 'label'=Get array of category
* labels, 'id'= Get array of category IDs
* @return mixed Array of category objects or < 0 if KO
* @param int $id Id of element
* @param int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...)
* @param string $mode 'id'=Get array of category ids, 'object'=Get array of fetched category instances, 'label'=Get array of category
* labels, 'id'= Get array of category IDs
* @return mixed Array of category objects or < 0 if KO
*/
function containing($id, $type, $mode='object')
{
$cats = array();
// For backward compatibility
if (is_numeric($type))
{
dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
// We want to reverse lookup
$map_type = array_flip($this->MAP_ID);
$type = $map_type[$type];
}
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type];
if ($type == Categorie::TYPE_BANK_LINE) // TODO Remove this with standard category code
{

View File

@ -1311,7 +1311,7 @@ else
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
print $langs->trans('RIB');
print '<td>';
if (($action != 'editbankaccount') && $user->rights->commande->creer && ! empty($object->brouillon))
if (($action != 'editbankaccount') && $user->rights->facture->creer && ! empty($object->brouillon))
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';

View File

@ -380,7 +380,7 @@ if (($action=="create") || ($action=="edit"))
print '<tr class="blockmethod"><td>';
print $langs->trans('CronArgs')."</td><td>";
print "<input type=\"text\" size=\"20\" name=\"params\" value=\"".$object->params."\" /> ";
print "<input type=\"text\" class=\"quatrevingtpercent\" name=\"params\" value=\"".$object->params."\" /> ";
print "</td>";
print "<td>";
print $form->textwithpicto('',$langs->trans("CronArgsHelp"),1,'help');
@ -408,10 +408,10 @@ if (($action=="create") || ($action=="edit"))
print '<tr><td class="fieldrequired">';
print $langs->trans('CronEvery')."</td>";
print "<td>";
print "<select name=\"nbfrequency\">";
for($i=1; $i<=60; $i++)
print '<select name="nbfrequency">';
for ($i=1; $i<=60; $i++)
{
if (! empty($object->unitfrequency) && ($object->frequency/$object->unitfrequency) == $i)
if ($object->frequency == $i)
{
print "<option value='".$i."' selected>".$i."</option>";
}

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* 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
@ -61,7 +61,7 @@ class Cronjob extends CommonObject
public $fk_user_mod;
public $nbrun;
public $libname;
public $test; // A test condition to know if job is visible/qualified
/**
* Constructor
@ -194,12 +194,12 @@ class Cronjob extends CommonObject
$sql.= " ".(! isset($this->md5params)?'NULL':"'".$this->db->escape($this->md5params)."'").",";
$sql.= " ".(! isset($this->module_name)?'NULL':"'".$this->db->escape($this->module_name)."'").",";
$sql.= " ".(! isset($this->priority)?'0':$this->priority).",";
$sql.= " ".(! isset($this->datelastrun) || dol_strlen($this->datelastrun)==0?'NULL':$this->db->idate($this->datelastrun)).",";
$sql.= " ".(! isset($this->datenextrun) || dol_strlen($this->datenextrun)==0?'NULL':$this->db->idate($this->datenextrun)).",";
$sql.= " ".(! isset($this->dateend) || dol_strlen($this->dateend)==0?'NULL':$this->db->idate($this->dateend)).",";
$sql.= " ".(! isset($this->datestart) || dol_strlen($this->datestart)==0?'NULL':$this->db->idate($this->datestart)).",";
$sql.= " ".(! isset($this->datelastrun) || dol_strlen($this->datelastrun)==0?'NULL':"'".$this->db->idate($this->datelastrun)."'").",";
$sql.= " ".(! isset($this->datenextrun) || dol_strlen($this->datenextrun)==0?'NULL':"'".$this->db->idate($this->datenextrun)."'").",";
$sql.= " ".(! isset($this->dateend) || dol_strlen($this->dateend)==0?'NULL':"'".$this->db->idate($this->dateend)."'").",";
$sql.= " ".(! isset($this->datestart) || dol_strlen($this->datestart)==0?'NULL':"'".$this->db->idate($this->datestart)."'").",";
$sql.= " ".(! isset($this->lastresult)?'NULL':"'".$this->db->escape($this->lastresult)."'").",";
$sql.= " ".(! isset($this->datelastresult) || dol_strlen($this->datelastresult)==0?'NULL':$this->db->idate($this->datelastresult)).",";
$sql.= " ".(! isset($this->datelastresult) || dol_strlen($this->datelastresult)==0?'NULL':"'".$this->db->idate($this->datelastresult)."'").",";
$sql.= " ".(! isset($this->lastoutput)?'NULL':"'".$this->db->escape($this->lastoutput)."'").",";
$sql.= " ".(! isset($this->unitfrequency)?'NULL':"'".$this->unitfrequency."'").",";
$sql.= " ".(! isset($this->frequency)?'0':$this->frequency).",";

View File

@ -18,7 +18,7 @@
*/
/**
* \file htdocs/cron/cron/list.php
* \file htdocs/cron/list.php
* \ingroup cron
* \brief Lists Jobs
*/
@ -356,11 +356,7 @@ if ($num > 0)
if (! verifCond($obj->test)) continue; // Discard line with test = false
// title profil
if ($style=='pair') {$style='impair';}
else {$style='pair';}
print '<tr class="'.$style.'">';
print '<tr class="oddeven">';
print '<td class="nowrap">';
print '<a href="'.DOL_URL_ROOT.'/cron/card.php?id='.$obj->rowid.'">';

View File

@ -14,6 +14,8 @@ FileToLaunchCronJobs=Command line to launch cron jobs
CronExplainHowToRunUnix=On Unix environment you should use the following crontab entry to run the command line each 5 minutes
CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run the command line each 5 minutes
CronMethodDoesNotExists=Class %s does not contains any method %s
CronJobDefDesc=Cron job profiles are defined into the module descriptor file. When module is activated, they are loaded and available so you can administer the jobs from the admin tools menu %s.
CronJobProfiles=List of predefined cron job profiles
# Menu
EnabledAndDisabled=Enabled and disabled
# Page list
@ -53,16 +55,17 @@ CronSaveSucess=Save successfully
CronNote=Comment
CronFieldMandatory=Fields %s is mandatory
CronErrEndDateStartDt=End date cannot be before start date
StatusAtInstall=Status at installation
CronStatusActiveBtn=Enable
CronStatusInactiveBtn=Disable
CronTaskInactive=This job is disabled
CronId=Id
CronClassFile=Filename with class
CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value for module is <i>product</i>
CronClassFileHelp=The relative path and file name to load (path is relative to web server root directory). <BR> For exemple to call the fetch method of Dolibarr Product object htdocs/product/class/<u>product.class.php</u>, the value for class file name is <i>product/class/product.class.php</i>
CronObjectHelp=The object name to load. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for class file name is <i>Product</i>
CronMethodHelp=The object method to launch. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for method is <i>fecth</i>
CronArgsHelp=The method arguments. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for paramters can be <i>0, ProductRef</i>
CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value for module is<br><i>product</i>
CronClassFileHelp=The relative path and file name to load (path is relative to web server root directory). <BR> For exemple to call the fetch method of Dolibarr Product object htdocs/product/class/<u>product.class.php</u>, the value for class file name is<br><i>product/class/product.class.php</i>
CronObjectHelp=The object name to load. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for class file name is<br><i>Product</i>
CronMethodHelp=The object method to launch. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for method is<br><i>fetch</i>
CronArgsHelp=The method arguments. <BR> For exemple to call the fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value for paramters can be<br><i>0, ProductRef</i>
CronCommandHelp=The system command line to execute.
CronCreateJob=Create new Scheduled Job
CronFrom=From

View File

@ -28,9 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$langs->load("admin");
$langs->load("modulebuilder");
$langs->load("other");
$langs->loadLangs(array("admin", "modulebuilder", "other", "cron"));
$action=GETPOST('action','aZ09');
$confirm=GETPOST('confirm','alpha');
@ -690,43 +688,24 @@ print load_fiche_titre($text, '', 'title_setup');
$listofmodules=array();
/*
if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder
{
global $dolibarr_main_document_root_alt;
if (! empty($dolibarr_main_document_root_alt) && is_array($dolibarr_main_document_root_alt))
{
foreach ($dolibarr_main_document_root_alt as $diralt)
{*/
$dirsincustom=dol_dir_list($dirins, 'directories');
if (is_array($dirsincustom) && count($dirsincustom) > 0)
{
foreach ($dirsincustom as $dircustomcursor)
{
$fullname = $dircustomcursor['fullname'];
if (dol_is_file($fullname.'/'.$FILEFLAG))
{
// Get real name of module (MyModule instead of mymodule)
$descriptorfiles = dol_dir_list($fullname.'/core/modules/', 'files', 0, 'mod.*\.class\.php$');
$modulenamewithcase='';
foreach($descriptorfiles as $descriptorcursor)
{
$modulenamewithcase=preg_replace('/^mod/', '', $descriptorcursor['name']);
$modulenamewithcase=preg_replace('/\.class\.php$/', '', $modulenamewithcase);
}
if ($modulenamewithcase) $listofmodules[$dircustomcursor['name']]=$modulenamewithcase;
//var_dump($listofmodules);
}
}
}
/* }
}
else
{
$newmenu->add('', 'NoGeneratedModuleFound', 0, 0);
}*/
$dirsincustom=dol_dir_list($dirins, 'directories');
if (is_array($dirsincustom) && count($dirsincustom) > 0) {
foreach ($dirsincustom as $dircustomcursor) {
$fullname = $dircustomcursor['fullname'];
if (dol_is_file($fullname . '/' . $FILEFLAG)) {
// Get real name of module (MyModule instead of mymodule)
$descriptorfiles = dol_dir_list($fullname . '/core/modules/', 'files', 0, 'mod.*\.class\.php$');
$modulenamewithcase = '';
foreach ($descriptorfiles as $descriptorcursor) {
$modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']);
$modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase);
}
if ($modulenamewithcase)
$listofmodules[$dircustomcursor['name']] = $modulenamewithcase;
// var_dump($listofmodules);
}
}
}
// Show description of content
$newdircustom=$dirins;
@ -764,7 +743,6 @@ if ($message)
}
print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>';
//print '<br>';
// Load module descriptor
@ -930,6 +908,11 @@ elseif (! empty($module))
$head2[$h][2] = 'widgets';
$h++;
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module;
$head2[$h][1] = $langs->trans("CronList");
$head2[$h][2] = 'cron';
$h++;
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module;
$head2[$h][1] = $langs->trans("BuildPackage");
$head2[$h][2] = 'buildpackage';
@ -1560,6 +1543,119 @@ elseif (! empty($module))
}
}
if ($tab == 'cron')
{
$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
$cronjobs = $moduleobj->cronjobs;
if ($action != 'editfile' || empty($file))
{
print $langs->trans("CronJobDefDesc", '<a href="'.DOL_URL_ROOT.'/cron/list.php?status=-2">'.$langs->trans('CronList').'</a>').'<br>';
print '<br>';
print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>';
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>';
print '<br>';
print load_fiche_titre($langs->trans("CronJobProfiles"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="addproperty">';
print '<input type="hidden" name="tab" value="objects">';
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
print '<div class="div-table-responsive">';
print '<table class="noborder">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronTask"),'','',"",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("StatusAtInstall"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Comment"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
print "</tr>\n";
foreach ($cronjobs as $cron)
{
print '<tr class="oddeven">';
print '<td>';
print $cron['label'];
print '</td>';
print '<td>';
if ($cron['jobtype']=='method')
{
$text=$langs->trans("CronClass");
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
}
elseif ($cron['jobtype']=='command')
{
$text=$langs->trans('CronCommand');
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
}
print $form->textwithpicto($text, $texttoshow, 1);
print '</td>';
print '<td>';
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
print '</td>';
print '<td>';
print $cron['status'];
print '</td>';
print '<td>';
if (!empty($cron['comment'])) {print $cron['comment'];}
print '</td>';
print '</tr>';
}
print '</table>';
print '</div>';
}
else
{
$fullpathoffile=dol_buildpath($file, 0);
$content = file_get_contents($fullpathoffile);
// New module
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="savefile">';
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
print '<input type="hidden" name="tab" value="'.$tab.'">';
print '<input type="hidden" name="module" value="'.$module.'">';
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
print '<br>';
print '<center>';
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</center>';
print '</form>';
}
}
if ($tab == 'buildpackage')
{
if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP'))

View File

@ -186,12 +186,13 @@ class modMyModule extends DolibarrModules
);
// Cronjobs
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array(
0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/mymodulemyjob.class.php', 'objectname'=>'MyModuleMyJob', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'test'=>true)
); // List of cron jobs entries to add
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'test'=>true),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'test'=>true)
0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/mymodulemyjob.class.php', 'objectname'=>'MyModuleMyJob', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true)
);
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
// );