';
- print '
';
+ dol_fiche_end();
+
+ print '
';
+ print ' ';
print '
';
print '';
}
// Part to show record
-if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
- $res = $object->fetch_optionals();
+if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
+{
+ $res = $object->fetch_optionals();
$head = myobjectPrepareHead($object);
- print dol_get_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule');
+ dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule');
$formconfirm = '';
// Confirmation to delete
- if ($action == 'delete') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
+ if ($action == 'delete')
+ {
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
}
// Clone confirmation
@@ -218,9 +230,10 @@
}
// Confirmation of action xxxx
- if ($action == 'xxx') {
+ if ($action == 'xxx')
+ {
$formquestion = array();
- /*
+ /*
$forcecombo=0;
if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy
$formquestion = array(
@@ -230,7 +243,7 @@
// array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo))
);
*/
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
}
// Call Hook formConfirm
@@ -309,30 +322,35 @@
print '
';
- print dol_get_fiche_end();
+ dol_fiche_end();
// Buttons for actions
if ($action != 'presend' && $action != 'editline') {
- print '
'."\n";
- $parameters = array();
- $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
- if (empty($reshook)) {
- // Modify
- if ($user->rights->mymodule->write) {
- print '
id.'&action=edit">'.$langs->trans("Modify").''."\n";
- } else {
- print '
'.$langs->trans('Modify').''."\n";
- }
-
- // Clone
- if ($user->rights->mymodule->write) {
- print '
';
- }
-
- /*
+ print '
'."\n";
+ $parameters = array();
+ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+ if (empty($reshook))
+ {
+ // Modify
+ if ($user->rights->mymodule->write)
+ {
+ print '
id.'&action=edit">'.$langs->trans("Modify").''."\n";
+ }
+ else
+ {
+ print '
'.$langs->trans('Modify').''."\n";
+ }
+
+ // Clone
+ if ($user->rights->mymodule->write)
+ {
+ print '
';
+ }
+
+ /*
if ($user->rights->mymodule->write)
{
if ($object->status == 1)
@@ -346,13 +364,16 @@
}
*/
- if ($user->rights->mymodule->delete) {
- print '
id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').''."\n";
- } else {
- print '
'.$langs->trans('Delete').''."\n";
- }
- }
- print '
'."\n";
+ if ($user->rights->mymodule->delete)
+ {
+ print '
id.'&action=delete">'.$langs->trans('Delete').''."\n";
+ }
+ else
+ {
+ print '
'.$langs->trans('Delete').''."\n";
+ }
+ }
+ print '
'."\n";
}
@@ -361,30 +382,54 @@
$action = 'presend';
}
- if ($action != 'presend') {
- print '
';
- print '
'; // ancre
-
- // Show links to link elements
- $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
- $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
-
-
- print '
';
-
- $MAXEVENT = 10;
-
- $morehtmlright = '
';
- $morehtmlright .= $langs->trans("SeeAll");
- $morehtmlright .= '';
-
- // List of actions on element
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
- $formactions = new FormActions($db);
- $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
-
- print '
';
- }
+ if ($action != 'presend')
+ {
+ print '
';
+ print '
'; // ancre
+
+ // Documents
+ /*$objref = dol_sanitizeFileName($object->ref);
+ $relativepath = $comref . '/' . $comref . '.pdf';
+ $filedir = $conf->mymodule->dir_output . '/' . $objref;
+ $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
+ $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content
+ $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card
+ print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
+ */
+
+ // Show links to link elements
+ $linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject'));
+ $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+
+
+ print '
';
+
+ $MAXEVENT = 10;
+
+ $morehtmlright = '
';
+ $morehtmlright .= $langs->trans("SeeAll");
+ $morehtmlright .= '';
+
+ // List of actions on element
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+ $formactions = new FormActions($db);
+ $somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
+
+ print '
';
+ }
+
+ //Select mail models is same action as presend
+ /*
+ if (GETPOST('modelselected')) $action = 'presend';
+
+ // Presend form
+ $modelmail='inventory';
+ $defaulttopic='InformationMessage';
+ $diroutput = $conf->product->dir_output.'/inventory';
+ $trackid = 'stockinv'.$object->id;
+
+ include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
+ */
}
// End of page
--- /tmp/dsg/dolibarr/htdocs/zapier/github_hook_document.php
+++ /tmp/dsg/dolibarr/htdocs/zapier/client_hook_document.php
@@ -92,19 +92,21 @@
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
-if ($object->id) {
+if ($object->id)
+{
/*
* Show tabs
*/
$head = myobjectPrepareHead($object);
- print dol_get_fiche_head($head, 'document', $langs->trans("MyObject"), -1, 'myobject@mymodule');
+ dol_fiche_head($head, 'document', $langs->trans("MyObject"), -1, 'myobject@mymodule');
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
- foreach ($filearray as $key => $file) {
+ foreach ($filearray as $key => $file)
+ {
$totalsize += $file['size'];
}
@@ -114,9 +116,9 @@
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
- print '
';
+ print '
';
- print '
';
+ print '
';
print '
';
// Number of files
@@ -129,8 +131,10 @@
print '';
- print dol_get_fiche_end();
-} else {
+ dol_fiche_end();
+}
+else
+{
accessforbidden('', 0, 0);
}
--- /tmp/dsg/dolibarr/htdocs/zapier/github_hook_list.php
+++ /tmp/dsg/dolibarr/htdocs/zapier/client_hook_list.php
@@ -28,10 +28,10 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php';
+require_once __DIR__.'/class/hook.class.php';
// Load translation files required by the page
-$langs->loadLangs(array("zapier", "other"));
+$langs->loadLangs(array("mymodule@mymodule", "other"));
// The action 'add', 'create', 'edit', 'update', 'view', ...
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view';
@@ -41,7 +41,7 @@
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
-$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'zapierlist'; // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'hooklist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
@@ -49,12 +49,12 @@
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST('sortfield', 'aZ09comma');
-$sortorder = GETPOST('sortorder', 'aZ09comma');
-$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : (int) GETPOST("page", 'int');
+$sortfield = GETPOST('sortfield', 'alpha');
+$sortorder = GETPOST('sortorder', 'alpha');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
- // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
- $page = 0;
+ // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
+ $page = 0;
}
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -65,9 +65,9 @@
// Initialize technical objects
$object = new Hook($db);
$extrafields = new ExtraFields($db);
-$diroutputmassaction = $conf->zapier->dir_output.'/temp/massgeneration/'.$user->id;
+$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id;
// Note that conf->hooks_modules contains array
-$hookmanager->initHooks(array('zapierhooklist'));
+$hookmanager->initHooks(array('hooklist'));
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
@@ -76,44 +76,48 @@
// Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) {
- // Set here default search field. By default 1st field in definition.
- $sortfield = "t.".key($object->fields);
+ // Set here default search field. By default 1st field in definition.
+ $sortfield = "t.".key($object->fields);
}
if (!$sortorder) {
- $sortorder = "ASC";
+ $sortorder = "ASC";
}
// Security check
$socid = 0;
if ($user->socid > 0) {
- // Protection if external user
- //$socid = $user->socid;
- accessforbidden();
-}
-//$result = restrictedArea($user, 'zapier', $id, '');
+ // Protection if external user
+ //$socid = $user->socid;
+ accessforbidden();
+}
+//$result = restrictedArea($user, 'mymodule', $id, '');
// Initialize array of search criterias
-$search_all = GETPOST("search_all", 'alpha');
+$search_all = trim(GETPOST("search_all", 'alpha'));
$search = array();
foreach ($object->fields as $key => $val) {
- if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
+ if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
foreach ($object->fields as $key => $val) {
- if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
+ if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
}
// Definition of fields for list
$arrayfields = array();
foreach ($object->fields as $key => $val) {
- // If $val['visible']==0, then we never show the field
- if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
+ // If $val['visible']==0, then we never show the field
+ if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
}
// Extra fields
-include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
-
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
+ $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
+ }
+}
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
@@ -124,11 +128,11 @@
*/
if (GETPOST('cancel', 'alpha')) {
- $action = 'list';
- $massaction = '';
+ $action = 'list';
+ $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
- $massaction = '';
+ $massaction = '';
}
$parameters = array();
@@ -136,30 +140,30 @@
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
-
- // Purge search criteria
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
- // All tests are required to be compatible with all browsers
- foreach ($object->fields as $key => $val) {
- $search[$key] = '';
- }
- $toselect = '';
- $search_array_options = array();
- }
- if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
- || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
- $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
- }
-
- // Mass actions
- $objectclass = 'Hook';
- $objectlabel = 'Hook';
- $permissiontoread = $user->rights->zapier->read;
- $permissiontodelete = $user->rights->zapier->delete;
- $uploaddir = $conf->zapier->dir_output;
- include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
+ // Selection of new fields
+ include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
+
+ // Purge search criteria
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
+ // All tests are required to be compatible with all browsers
+ foreach ($object->fields as $key => $val) {
+ $search[$key] = '';
+ }
+ $toselect = '';
+ $search_array_options = array();
+ }
+ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
+ || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
+ $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
+ }
+
+ // Mass actions
+ $objectclass = 'Hook';
+ $objectlabel = 'Hook';
+ $permissiontoread = $user->rights->mymodule->read;
+ $permissiontodelete = $user->rights->mymodule->delete;
+ $uploaddir = $conf->mymodule->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -181,13 +185,13 @@
// --------------------------------------------------------------------
$sql = 'SELECT ';
foreach ($object->fields as $key => $val) {
- $sql .= 't.'.$key.', ';
+ $sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
- $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
- }
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
+ }
}
// Add fields from hooks
$parameters = array();
@@ -197,21 +201,21 @@
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
if ($object->ismultientitymanaged == 1) {
- $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
+ $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
} else {
- $sql .= " WHERE 1 = 1";
+ $sql .= " WHERE 1 = 1";
}
foreach ($search as $key => $val) {
- if ($key == 'status' && $search[$key] == -1) {
- continue;
- }
- $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
- if ($search[$key] != '') {
- $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
- }
+ if ($key == 'status' && $search[$key] == -1) {
+ continue;
+ }
+ $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
+ if ($search[$key] != '') {
+ $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
+ }
}
if ($search_all) {
- $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
+ $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -241,35 +245,35 @@
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
- $resql = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($resql);
- if (($page * $limit) > $nbtotalofrecords) {
- // if total of record found is smaller than page * limit, goto and load page 0
- $page = 0;
- $offset = 0;
- }
+ $resql = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($resql);
+ if (($page * $limit) > $nbtotalofrecords) {
+ // if total of record found is smaller than page * limit, goto and load page 0
+ $page = 0;
+ $offset = 0;
+ }
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
- $num = $nbtotalofrecords;
+ $num = $nbtotalofrecords;
} else {
- $sql .= $db->plimit($limit + 1, $offset);
-
- $resql = $db->query($sql);
- if (!$resql) {
- dol_print_error($db);
- exit;
- }
-
- $num = $db->num_rows($resql);
+ $sql .= $db->plimit($limit + 1, $offset);
+
+ $resql = $db->query($sql);
+ if (!$resql) {
+ dol_print_error($db);
+ exit;
+ }
+
+ $num = $db->num_rows($resql);
}
// Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
- $obj = $db->fetch_object($resql);
- $id = $obj->rowid;
- header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id);
- exit;
+ $obj = $db->fetch_object($resql);
+ $id = $obj->rowid;
+ header("Location: ".dol_buildpath('/zapierfordolibarr/hook_card.php', 1).'?id='.$id);
+ exit;
}
@@ -279,19 +283,19 @@
llxHeader('', $title, $help_url);
// Example : Adding jquery code
-// print '';
+print '';
$arrayofselected = is_array($toselect) ? $toselect : array();
@@ -299,13 +303,13 @@
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
foreach ($search as $key => $val) {
- if (is_array($search[$key]) && count($search[$key])) {
- foreach ($search[$key] as $skey) {
- $param .= '&search_'.$key.'[]='.urlencode($skey);
- }
- } else {
- $param .= '&search_'.$key.'='.urlencode($search[$key]);
- }
+ if (is_array($search[$key]) && count($search[$key])) {
+ foreach ($search[$key] as $skey) {
+ $param .= '&search_'.$key.'[]='.urlencode($skey);
+ }
+ } else {
+ $param .= '&search_'.$key.'='.urlencode($search[$key]);
+ }
}
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
@@ -313,10 +317,10 @@
// List of mass actions available
$arrayofmassactions = array(
- //'presend'=>$langs->trans("SendByMail"),
- //'builddoc'=>$langs->trans("PDFMerge"),
+ //'presend'=>$langs->trans("SendByMail"),
+ //'builddoc'=>$langs->trans("PDFMerge"),
);
-if ($user->rights->zapier->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
+if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
@@ -331,11 +335,11 @@
print '';
$newcardbutton = '';
-//if ($user->rights->zapier->creer)
+//if ($user->rights->mymodule->creer)
//{
- $newcardbutton = ''.$langs->trans('New').'';
- $newcardbutton .= '';
- $newcardbutton .= '';
+ $newcardbutton = ''.$langs->trans('New').'';
+ $newcardbutton .= '';
+ $newcardbutton .= '';
//}
//else
//{
@@ -350,12 +354,12 @@
$topicmail = "SendHookRef";
$modelmail = "hook";
$objecttmp = new Hook($db);
-$trackid = 'zapier'.$object->id;
+$trackid = 'xxxx'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall) {
- foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
- print ''.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
';
+ foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
+ print ''.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
';
}
$moreforfilter = '';
@@ -369,9 +373,9 @@
else $moreforfilter = $hookmanager->resPrint;
if (!empty($moreforfilter)) {
- print '';
- print $moreforfilter;
- print '
';
+ print '';
+ print $moreforfilter;
+ print '
';
}
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
@@ -386,22 +390,22 @@
// --------------------------------------------------------------------
print '';
foreach ($object->fields as $key => $val) {
- $cssforfield = '';
- if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- }
- if (in_array($val['type'], array('timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- }
- if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'right';
- }
- if ($key == 'status') {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- }
- if (!empty($arrayfields['t.'.$key]['checked'])) {
- print ' | ';
- }
+ $cssforfield = '';
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ }
+ if (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ }
+ if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
+ if ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ }
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
+ print ' | ';
+ }
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -422,25 +426,25 @@
// --------------------------------------------------------------------
print '
';
foreach ($object->fields as $key => $val) {
- $cssforfield = '';
- if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
- if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
- if ($key == 'status') {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- }
- if (!empty($arrayfields['t.'.$key]['checked'])) {
- print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
- }
+ $cssforfield = '';
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ if ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ }
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
+ print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
+ }
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array(
- 'arrayfields' => $arrayfields,
- 'param' => $param,
- 'sortfield' => $sortfield,
- 'sortorder' => $sortorder,
+ 'arrayfields' => $arrayfields,
+ 'param' => $param,
+ 'sortfield' => $sortfield,
+ 'sortorder' => $sortorder,
);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -452,12 +456,12 @@
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
- foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
- if (preg_match('/\$object/', $val)) {
- // There is at least one compute field that use $object
- $needToFetchEachLine++;
- }
- }
+ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
+ if (preg_match('/\$object/', $val)) {
+ // There is at least one compute field that use $object
+ $needToFetchEachLine++;
+ }
+ }
}
@@ -466,71 +470,72 @@
$i = 0;
$totalarray = array();
while ($i < min($num, $limit)) {
- $obj = $db->fetch_object($resql);
- if (empty($obj)) {
- break; // Should not happen
- }
-
- // Store properties in $object
- $object->id = $obj->rowid;
- foreach ($object->fields as $key => $val) {
- if (isset($obj->$key)) $object->$key = $obj->$key;
- }
-
- // Show here line of result
- print '
';
- foreach ($object->fields as $key => $val) {
- $cssforfield = '';
- if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- } elseif ($key == 'status') {
- $cssforfield .= ($cssforfield ? ' ' : '').'center';
- }
-
- if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
-
- if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
-
- if (!empty($arrayfields['t.'.$key]['checked'])) {
- print '';
- if ($key == 'status') print $object->getLibStatut(5);
- elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
- else print $object->showOutputField($val, $key, $obj->$key, '');
- print ' | ';
- if (!$i) $totalarray['nbfield']++;
- if (!empty($val['isameasure'])) {
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
- $totalarray['val']['t.'.$key] += $obj->$key;
- }
- }
- }
- // Extra fields
- include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
- // Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
- $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Action column
- print '';
- if ($massactionbutton || $massaction) {
- // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- $selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
- print '';
- }
- print ' | ';
- if (!$i) $totalarray['nbfield']++;
-
- print '
';
-
- $i++;
+ $obj = $db->fetch_object($resql);
+ if (empty($obj)) {
+ break; // Should not happen
+ }
+
+ // Store properties in $object
+ $object->id = $obj->rowid;
+ foreach ($object->fields as $key => $val) {
+ if (isset($obj->$key)) $object->$key = $obj->$key;
+ }
+
+ // Show here line of result
+ print '';
+ foreach ($object->fields as $key => $val) {
+ $cssforfield = '';
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ }
+
+ if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+
+ if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real'))) $cssforfield .= ($cssforfield ? ' ' : '').'right';
+
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
+ print '';
+ if ($key == 'status') print $object->getLibStatut(5);
+ elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
+ else print $object->showOutputField($val, $key, $obj->$key, '');
+ print ' | ';
+ if (!$i) $totalarray['nbfield']++;
+ if (!empty($val['isameasure']))
+ {
+ if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ $totalarray['val']['t.'.$key] += $obj->$key;
+ }
+ }
+ }
+ // Extra fields
+ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+ // Fields from hook
+ $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
+ print $hookmanager->resPrint;
+ // Action column
+ print '';
+ if ($massactionbutton || $massaction) {
+ // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+ $selected = 0;
+ if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
+ print '';
+ }
+ print ' | ';
+ if (!$i) $totalarray['nbfield']++;
+
+ print '
';
+
+ $i++;
}
// Show total line
@@ -539,21 +544,21 @@
// If no record found
if ($num == 0) {
- $colspan = 1;
- foreach ($arrayfields as $key => $val) {
- if (!empty($val['checked'])) {
- $colspan++;
- }
- }
- print ''.$langs->trans("NoRecordFound").' |
';
+ $colspan = 1;
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
+ print ''.$langs->trans("NoRecordFound").' |
';
}
$db->free($resql);
$parameters = array(
- 'arrayfields' => $arrayfields,
- 'sql' => $sql,
+ 'arrayfields' => $arrayfields,
+ 'sql' => $sql,
);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -564,23 +569,23 @@
print ''."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
- $hidegeneratedfilelistifempty = 1;
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
- $hidegeneratedfilelistifempty = 0;
- }
-
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
- $formfile = new FormFile($db);
-
- // Show list of available documents
- $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
- $urlsource .= str_replace('&', '&', $param);
-
- $filedir = $diroutputmassaction;
- $genallowed = $user->rights->zapier->read;
- $delallowed = $user->rights->zapier->create;
-
- print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
+ $hidegeneratedfilelistifempty = 1;
+ if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
+ $hidegeneratedfilelistifempty = 0;
+ }
+
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+ $formfile = new FormFile($db);
+
+ // Show list of available documents
+ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
+ $urlsource .= str_replace('&', '&', $param);
+
+ $filedir = $diroutputmassaction;
+ $genallowed = $user->rights->mymodule->read;
+ $delallowed = $user->rights->mymodule->create;
+
+ print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
// End of page
--- /tmp/dsg/dolibarr/htdocs/zapier/github_hook_note.php
+++ /tmp/dsg/dolibarr/htdocs/zapier/client_hook_note.php
@@ -33,7 +33,7 @@
// Get parameters
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
-$action = GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
@@ -77,12 +77,13 @@
$help_url = '';
llxHeader('', $langs->trans('MyObject'), $help_url);
-if ($id > 0 || !empty($ref)) {
+if ($id > 0 || !empty($ref))
+{
$object->fetch_thirdparty();
$head = myobjectPrepareHead($object);
- print dol_get_fiche_head($head, 'note', $langs->trans("MyObject"), -1, 'myobject@mymodule');
+ dol_fiche_head($head, 'note', $langs->trans("MyObject"), -1, 'myobject@mymodule');
// Object card
// ------------------------------------------------------------
@@ -143,7 +144,7 @@
print '';
- print dol_get_fiche_end();
+ dol_fiche_end();
}
// End of page
--- /tmp/dsg/dolibarr/htdocs/zapier/github_zapierindex.php
+++ /tmp/dsg/dolibarr/htdocs/zapier/client_zapierindex.php
@@ -31,13 +31,14 @@
// Load translation files required by the page
$langs->loadLangs(array("zapier@zapier"));
-$action = GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'alpha');
// Securite acces client
if (!$user->rights->zapier->read) accessforbidden();
$socid = GETPOST('socid', 'int');
-if (isset($user->socid) && $user->socid > 0) {
+if (isset($user->socid) && $user->socid > 0)
+{
$action = '';
$socid = $user->socid;
}
@@ -67,8 +68,155 @@
print '';
+/* BEGIN MODULEBUILDER DRAFT MYOBJECT
+// Draft MyObject
+if (! empty($conf->zapier->enabled) && $user->rights->zapier->read)
+{
+ $langs->load("orders");
+
+ $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
+ $sql.= ", s.code_client";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
+ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE c.fk_soc = s.rowid";
+ $sql.= " AND c.fk_statut = 0";
+ $sql.= " AND c.entity IN (".getEntity('commande').")";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socid) $sql.= " AND c.fk_soc = ".$socid;
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $total = 0;
+ $num = $db->num_rows($resql);
+
+ print '
';
+ print '';
+ print ''.$langs->trans("DraftOrders").($num?''.$num.'':'').' |
';
+
+ $var = true;
+ if ($num > 0)
+ {
+ $i = 0;
+ while ($i < $num)
+ {
+
+ $obj = $db->fetch_object($resql);
+ print '';
+ $orderstatic->id=$obj->rowid;
+ $orderstatic->ref=$obj->ref;
+ $orderstatic->ref_client=$obj->ref_client;
+ $orderstatic->total_ht = $obj->total_ht;
+ $orderstatic->total_tva = $obj->total_tva;
+ $orderstatic->total_ttc = $obj->total_ttc;
+ print $orderstatic->getNomUrl(1);
+ print ' | ';
+ print '';
+ $companystatic->id=$obj->socid;
+ $companystatic->name=$obj->name;
+ $companystatic->client=$obj->client;
+ $companystatic->code_client = $obj->code_client;
+ $companystatic->code_fournisseur = $obj->code_fournisseur;
+ $companystatic->canvas=$obj->canvas;
+ print $companystatic->getNomUrl(1,'customer',16);
+ print ' | ';
+ print ''.price($obj->total_ttc).' |
';
+ $i++;
+ $total += $obj->total_ttc;
+ }
+ if ($total>0)
+ {
+
+ print ''.$langs->trans("Total").' | '.price($total)." |
";
+ }
+ }
+ else
+ {
+
+ print ''.$langs->trans("NoOrder").' |
';
+ }
+ print "
";
+
+ $db->free($resql);
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+END MODULEBUILDER DRAFT MYOBJECT */
+
+
print '
';
+
+$NBMAX = 3;
+$max = 3;
+
+/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
+// Last modified myobject
+if (! empty($conf->zapier->enabled) && $user->rights->zapier->read)
+{
+ $sql = "SELECT s.rowid, s.nom as name, s.client, s.datec, s.tms, s.canvas";
+ $sql.= ", s.code_client";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE s.client IN (1, 2, 3)";
+ $sql.= " AND s.entity IN (".getEntity($companystatic->element).")";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if ($socid) $sql.= " AND s.rowid = $socid";
+ $sql .= " ORDER BY s.tms DESC";
+ $sql .= $db->plimit($max, 0);
+
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ print '
';
+ print '';
+ print '';
+ if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastCustomersOrProspects",$max);
+ else if (! empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print $langs->trans("BoxTitleLastModifiedProspects",$max);
+ else print $langs->trans("BoxTitleLastModifiedCustomers",$max);
+ print ' | ';
+ print ''.$langs->trans("DateModificationShort").' | ';
+ print '
';
+ if ($num)
+ {
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($resql);
+ $companystatic->id=$objp->rowid;
+ $companystatic->name=$objp->name;
+ $companystatic->client=$objp->client;
+ $companystatic->code_client = $objp->code_client;
+ $companystatic->code_fournisseur = $objp->code_fournisseur;
+ $companystatic->canvas=$objp->canvas;
+ print '';
+ print ''.$companystatic->getNomUrl(1,'customer',48).' | ';
+ print '';
+ print $companystatic->getLibCustProspStatut();
+ print " | ";
+ print ''.dol_print_date($db->jdate($objp->tms),'day')." | ";
+ print '
';
+ $i++;
+
+
+ }
+
+ $db->free($resql);
+ }
+ else
+ {
+ print ''.$langs->trans("None").' |
';
+ }
+ print "
";
+ }
+}
+*/
print '
';