Ejemplo n.º 1
0
/**
 * Prepare array with list of tabs
 *
 * @param   ChargeSociales	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function tax_prepare_head(ChargeSociales $object)
{
    global $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/compta/sociales/charges.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Card');
    $head[$h][2] = 'card';
    $h++;
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'tax');
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->tax->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/compta/sociales/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/compta/sociales/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Info");
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'tax', 'remove');
    return $head;
}
Ejemplo n.º 2
0
/**
 * Prepare array with list of tabs
 *
 * @param   Object	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function fichinter_prepare_head($object)
{
    global $langs, $conf, $user;
    $langs->load("fichinter");
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/fichinter/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Card");
    $head[$h][2] = 'card';
    $h++;
    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
        $head[$h][0] = DOL_URL_ROOT . '/fichinter/contact.php?id=' . $object->id;
        $head[$h][1] = $langs->trans('InterventionContact');
        $head[$h][2] = 'contact';
        $h++;
    }
    if (!empty($conf->global->MAIN_USE_PREVIEW_TABS)) {
        $head[$h][0] = DOL_URL_ROOT . '/fichinter/apercu.php?id=' . $object->id;
        $head[$h][1] = $langs->trans('Preview');
        $head[$h][2] = 'preview';
        $h++;
    }
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention');
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = 0;
        if (!empty($object->note_private)) {
            $nbNote++;
        }
        if (!empty($object->note_public)) {
            $nbNote++;
        }
        $head[$h][0] = DOL_URL_ROOT . '/fichinter/note.php?id=' . $object->id;
        $head[$h][1] = $langs->trans('Notes');
        if ($nbNote > 0) {
            $head[$h][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$h][2] = 'note';
        $h++;
    }
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->ficheinter->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/fichinter/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/fichinter/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Info');
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention', 'remove');
    return $head;
}
Ejemplo n.º 3
0
/**
 *  Return array head with list of tabs to view object informations
 *
 *  @param	Object	$object         Holiday
 *  @return array           		head
 */
function holiday_prepare_head($object)
{
    global $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/holiday/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Card");
    $head[$h][2] = 'card';
    $h++;
    // Attachments
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->holiday->multidir_output[$object->entity] . '/' . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/holiday/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Documents');
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday');
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'holiday', 'remove');
    return $head;
}
Ejemplo n.º 4
0
/**
 *	Prepare array with list of tabs
 *
 *	@param	Donation	$object		Donation
 *	@return	array					Array of tabs to show
 */
function donation_prepare_head($object)
{
    global $db, $langs, $conf;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Card");
    $head[$h][2] = 'card';
    $h++;
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
    // $this->tabs = array('entity:-tabname); to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation');
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->don->dir_output . '/' . get_exdir($filename, 2, 0, 1, $object, 'donation') . '/' . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $nbLinks = Link::count($db, $object->element, $object->id);
    $head[$h][0] = DOL_URL_ROOT . '/don/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Documents');
    if ($nbFiles + $nbLinks > 0) {
        $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Info");
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
    return $head;
}
Ejemplo n.º 5
0
/**
 * Prepare array with list of tabs
 *
 * @param   Contact	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function contact_prepare_head(Contact $object)
{
    global $db, $langs, $conf, $user;
    $tab = 0;
    $head = array();
    $head[$tab][0] = DOL_URL_ROOT . '/contact/card.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Card");
    $head[$tab][2] = 'card';
    $tab++;
    if (!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_CONTACT_ACTIVE)) {
        $langs->load("ldap");
        $head[$tab][0] = DOL_URL_ROOT . '/contact/ldap.php?id=' . $object->id;
        $head[$tab][1] = $langs->trans("LDAPCard");
        $head[$tab][2] = 'ldap';
        $tab++;
    }
    $head[$tab][0] = DOL_URL_ROOT . '/contact/perso.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("PersonalInformations");
    $head[$tab][2] = 'perso';
    $tab++;
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact');
    // Notes
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1);
        $head[$tab][0] = DOL_URL_ROOT . '/contact/note.php?id=' . $object->id;
        $head[$tab][1] = $langs->trans("Note");
        if ($nbNote > 0) {
            $head[$tab][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$tab][2] = 'note';
        $tab++;
    }
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->societe->dir_output . "/contact/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $nbLinks = Link::count($db, $object->element, $object->id);
    $head[$tab][0] = DOL_URL_ROOT . '/contact/document.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Documents");
    if ($nbFiles + $nbLinks > 0) {
        $head[$tab][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$tab][2] = 'documents';
    $tab++;
    // Info
    $head[$tab][0] = DOL_URL_ROOT . '/contact/info.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Info");
    $head[$tab][2] = 'info';
    $tab++;
    complete_head_from_modules($conf, $langs, $object, $head, $tab, 'contact', 'remove');
    return $head;
}
Ejemplo n.º 6
0
/**
 * Prepare array with list of tabs
 *
 * @param   Account	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function bank_prepare_head(Account $object)
{
    global $db, $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/compta/bank/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("AccountCard");
    $head[$h][2] = 'bankname';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/account.php?id=" . $object->id;
    $head[$h][1] = $langs->trans("Transactions");
    $head[$h][2] = 'journal';
    $h++;
    //    if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
    //	{
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/treso.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("PlannedTransactions");
    $head[$h][2] = 'cash';
    $h++;
    //	}
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/annuel.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("IOMonthlyReporting");
    $head[$h][2] = 'annual';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/graph.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("Graph");
    $head[$h][2] = 'graph';
    $h++;
    if ($object->courant != 2) {
        $head[$h][0] = DOL_URL_ROOT . "/compta/bank/releve.php?account=" . $object->id;
        $head[$h][1] = $langs->trans("AccountStatements");
        $head[$h][2] = 'statement';
        $h++;
    }
    // Attached files
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->bank->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $nbLinks = Link::count($db, $object->element, $object->id);
    $head[$h][0] = DOL_URL_ROOT . "/compta/bank/document.php?account=" . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles + $nbLinks > 0) {
        $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$h][2] = 'document';
    $h++;
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank');
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank', 'remove');
    return $head;
}
Ejemplo n.º 7
0
/**
 * Prepare array with list of tabs
 *
 * @param   Contrat	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function contract_prepare_head(Contrat $object)
{
    global $db, $langs, $conf;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/contrat/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("ContractCard");
    $head[$h][2] = 'card';
    $h++;
    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
        $head[$h][0] = DOL_URL_ROOT . '/contrat/contact.php?id=' . $object->id;
        $head[$h][1] = $langs->trans("ContactsAddresses");
        $head[$h][2] = 'contact';
        $h++;
    }
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract');
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = 0;
        if (!empty($object->note_private)) {
            $nbNote++;
        }
        if (!empty($object->note_public)) {
            $nbNote++;
        }
        $head[$h][0] = DOL_URL_ROOT . '/contrat/note.php?id=' . $object->id;
        $head[$h][1] = $langs->trans("Notes");
        if ($nbNote > 0) {
            $head[$h][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$h][2] = 'note';
        $h++;
    }
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->contrat->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $nbLinks = Link::count($db, $object->element, $object->id);
    $head[$h][0] = DOL_URL_ROOT . '/contrat/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles + $nbLinks > 0) {
        $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/contrat/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Info");
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'contract', 'remove');
    return $head;
}
Ejemplo n.º 8
0
 /**
  *  Return list of printing driver
  *
  *  @param  DoliDB  $db                 Database handler
  *  @param  integer  $maxfilenamelength  Max length of value to show
  *  @return array                       List of drivers
  */
 static function listDrivers($db, $maxfilenamelength = 0)
 {
     global $conf;
     $type = 'printing';
     $list = array();
     $moduledir = DOL_DOCUMENT_ROOT . "/core/modules/printing/";
     $tmpfiles = dol_dir_list($moduledir, 'all', 0, '\\modules.php', '', 'name', SORT_ASC, 0);
     foreach ($tmpfiles as $record) {
         $list[$record['fullname']] = str_replace('.modules.php', '', $record['name']);
     }
     return $list;
 }
Ejemplo n.º 9
0
/**
 * Prepare array with list of tabs
 *
 * @param   Object	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function loan_prepare_head($object)
{
    global $langs, $conf;
    $tab = 0;
    $head = array();
    $head[$tab][0] = DOL_URL_ROOT . '/loan/card.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans('Card');
    $head[$tab][2] = 'card';
    $tab++;
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = (empty($object->note_private) ? 0 : 1) + (empty($object->note_public) ? 0 : 1);
        $head[$tab][0] = DOL_URL_ROOT . "/loan/note.php?id=" . $object->id;
        $head[$tab][1] = $langs->trans("Notes");
        if ($nbNote > 0) {
            $head[$tab][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$tab][2] = 'note';
        $tab++;
    }
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan');
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->loan->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$tab][0] = DOL_URL_ROOT . '/loan/document.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$tab][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$tab][2] = 'documents';
    $tab++;
    $head[$tab][0] = DOL_URL_ROOT . '/loan/info.php?id=' . $object->id;
    $head[$tab][1] = $langs->trans("Info");
    $head[$tab][2] = 'info';
    $tab++;
    complete_head_from_modules($conf, $langs, $object, $head, $tab, 'loan', 'remove');
    return $head;
}
        print ' <label for="' . $val['id'] . '">' . $val['label'] . '</label>';
    } else {
        print '<input type="radio" name="compression" value="' . $key . '" id="' . $val['id'] . '" disabled="disabled">';
        print ' <label for="' . $val['id'] . '">' . $val['label'] . '</label>';
        print ' (' . $langs->trans("NotAvailable") . ')';
    }
    print ' &nbsp; &nbsp; ';
}
print '</div>';
print "\n";
?>
</fieldset>

<br>
<div align="center"><input type="submit" class="button"
	value="<?php 
echo $langs->trans("GenerateBackup");
?>
" id="buttonGo" /><br>
<br>
</div>


</form>

<?php 
$filearray = dol_dir_list($conf->admin->dir_output . '/backup', 'files', 0, '', '', $sortfield, strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC, 1);
$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"));
print '<br>';
llxFooter();
$db->close();
Ejemplo n.º 11
0
    foreach ($listmodulepart as $modulepart)
    {
        $filearray=array();
        $upload_dir = isset($conf->$modulepart->dir_output)?$conf->$modulepart->dir_output:'';
        if ($modulepart == 'company') $upload_dir = $conf->societe->dir_output; // TODO change for multicompany sharing
        if ($modulepart == 'invoice') $upload_dir = $conf->facture->dir_output;
        if ($modulepart == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
        if ($modulepart == 'order') $upload_dir = $conf->commande->dir_output;
        if ($modulepart == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
        if ($modulepart == 'contract') $upload_dir = $conf->contrat->dir_output;

        if (empty($upload_dir)) continue;

        print '<tr><td colspan="2">Clean orphelins files into files '.$upload_dir.'</td></tr>';

        $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','(\.meta|_preview\.png)$','^temp$','^payments$','^CVS$','^thumbs$'),'',SORT_DESC,1);

        // To show ref or specific information according to view to show (defined by $module)
        if ($modulepart == 'invoice')
        {
            include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
            $object_instance=new Facture($db);
        }
        else if ($modulepart == 'invoice_supplier')
        {
            include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
            $object_instance=new FactureFournisseur($db);
        }
        else if ($modulepart == 'propal')
        {
            include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
 /**
  *	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="setModuleOptions">';
     $texte .= '<input type="hidden" name="param1" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH">';
     if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) {
         $texte .= '<input type="hidden" name="param2" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT">';
         $texte .= '<input type="hidden" name="param3" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL">';
         $texte .= '<input type="hidden" name="param4" value="SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED">';
     }
     $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->SUPPLIER_PROPOSAL_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, '\\.(ods|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 .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
     $texte .= '<textarea class="flat" cols="60" name="value1">';
     $texte .= $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH;
     $texte .= '</textarea>';
     $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
     $texte .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="Button">';
     $texte .= '<br></div></div>';
     // Scan directories
     if (count($listofdir)) {
         $texte .= $langs->trans("NumberOfModelFilesFound") . ': <b>' . count($listoffiles) . '</b>';
         if ($conf->global->MAIN_SUPPLIER_PROPOSAL_CHOOSE_ODT_DOCUMENT > 0) {
             // Model for creation
             $liste = ModelePDFSupplierProposal::liste_modeles($this->db);
             $texte .= '<table width="50%;">';
             $texte .= '<tr>';
             $texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalCreate") . '</td>';
             $texte .= '<td colspan="">';
             $texte .= $form->selectarray('value2', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT);
             $texte .= "</td></tr>";
             $texte .= '<tr>';
             $texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalToBill") . '</td>';
             $texte .= '<td colspan="">';
             $texte .= $form->selectarray('value3', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL);
             $texte .= "</td></tr>";
             $texte .= '<tr>';
             $texte .= '<td width="60%;">' . $langs->trans("DefaultModelSupplierProposalClosed") . '</td>';
             $texte .= '<td colspan="">';
             $texte .= $form->selectarray('value4', $liste, $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED);
             $texte .= "</td></tr>";
             $texte .= '</table>';
         }
     }
     $texte .= '</td>';
     $texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
     $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
     $texte .= '</td>';
     $texte .= '</tr>';
     $texte .= '</table>';
     $texte .= '</form>';
     return $texte;
 }
Ejemplo n.º 13
0
$diroutputpdf = $conf->facture->dir_output . '/unpaid/temp';
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'facture', $id, '');
/*
 * Action
 */
if ($action == "builddoc" && $user->rights->facture->lire) {
    if (is_array($_POST['toGenerate'])) {
        $arrayofexclusion = array();
        foreach ($_POST['toGenerate'] as $tmppdf) {
            $arrayofexclusion[] = preg_quote($tmppdf . '.pdf', '/');
        }
        $factures = dol_dir_list($conf->facture->dir_output, 'all', 1, implode('|', $arrayofexclusion), '\\.meta$|\\.png', 'date', SORT_DESC);
        // liste les fichiers
        $files = array();
        $factures_bak = $factures;
        foreach ($_POST['toGenerate'] as $basename) {
            foreach ($factures as $facture) {
                if (strstr($facture["name"], $basename)) {
                    $files[] = $conf->facture->dir_output . '/' . $basename . '/' . $facture["name"];
                }
            }
        }
        // Define output language (Here it is not used because we do only merging existing PDF)
        $outputlangs = $langs;
        $newlang = '';
        if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) {
            $newlang = GETPOST('lang_id');
Ejemplo n.º 14
0
/**
 * Prepare array with list of tabs
 *
 * @param   object	$object		Object related to tabs
 * @return  array				Array of tabs to show
 */
function actions_prepare_head($object)
{
    global $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/comm/action/card.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("CardAction");
    $head[$h][2] = 'card';
    $h++;
    // Attached files
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->agenda->dir_output . "/" . $object->id;
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/comm/action/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Documents");
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/comm/action/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Info');
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'action');
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'action', 'remove');
    return $head;
}
Ejemplo n.º 15
0
/**
 * Initialize the array of tabs for customer invoice
 *
 * @param	Facture		$object		Invoice object
 * @return	array					Array of head tabs
 */
function facture_prepare_head($object)
{
    global $langs, $conf;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/compta/facture.php?facid=' . $object->id;
    $head[$h][1] = $langs->trans('CardBill');
    $head[$h][2] = 'compta';
    $h++;
    if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
        $head[$h][0] = DOL_URL_ROOT . '/compta/facture/contact.php?facid=' . $object->id;
        $head[$h][1] = $langs->trans('ContactsAddresses');
        $head[$h][2] = 'contact';
        $h++;
    }
    if (!empty($conf->global->MAIN_USE_PREVIEW_TABS)) {
        $head[$h][0] = DOL_URL_ROOT . '/compta/facture/apercu.php?facid=' . $object->id;
        $head[$h][1] = $langs->trans('Preview');
        $head[$h][2] = 'preview';
        $h++;
    }
    //if ($fac->mode_reglement_code == 'PRE')
    if (!empty($conf->prelevement->enabled)) {
        $head[$h][0] = DOL_URL_ROOT . '/compta/facture/prelevement.php?facid=' . $object->id;
        $head[$h][1] = $langs->trans('StandingOrders');
        $head[$h][2] = 'standingorders';
        $h++;
    }
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname);   												to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice');
    if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
        $nbNote = 0;
        if (!empty($object->note_private)) {
            $nbNote++;
        }
        if (!empty($object->note_public)) {
            $nbNote++;
        }
        $head[$h][0] = DOL_URL_ROOT . '/compta/facture/note.php?facid=' . $object->id;
        $head[$h][1] = $langs->trans('Notes');
        if ($nbNote > 0) {
            $head[$h][1] .= ' <span class="badge">' . $nbNote . '</span>';
        }
        $head[$h][2] = 'note';
        $h++;
    }
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $head[$h][0] = DOL_URL_ROOT . '/compta/facture/document.php?facid=' . $object->id;
    $head[$h][1] = $langs->trans('Documents');
    if ($nbFiles > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbFiles . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/compta/facture/info.php?facid=' . $object->id;
    $head[$h][1] = $langs->trans('Info');
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'invoice', 'remove');
    return $head;
}
Ejemplo n.º 16
0
 /**
  *  Validate object and update stock if option enabled
  *
  *  @param      User		$user       Object user that validate
  *  @param		int			$notrigger	1=Does not execute triggers, 0= execuete triggers
  *  @return     int						<0 if OK, >0 if KO
  */
 function valid($user, $notrigger = 0)
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     dol_syslog(get_class($this) . "::valid");
     // Protection
     if ($this->statut) {
         dol_syslog(get_class($this) . "::valid no draft status", LOG_WARNING);
         return 0;
     }
     if (!(empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->creer) || !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->expedition->shipping_advance->validate))) {
         $this->error = 'Permission denied';
         dol_syslog(get_class($this) . "::valid " . $this->error, LOG_ERR);
         return -1;
     }
     $this->db->begin();
     $error = 0;
     // Define new ref
     $soc = new Societe($this->db);
     $soc->fetch($this->socid);
     // Class of company linked to order
     $result = $soc->set_as_client();
     // Define new ref
     if (!$error && (preg_match('/^[\\(]?PROV/i', $this->ref) || empty($this->ref))) {
         $numref = $this->getNextNumRef($soc);
     } else {
         $numref = "EXP" . $this->id;
     }
     $this->newref = $numref;
     $now = dol_now();
     // Validate
     $sql = "UPDATE " . MAIN_DB_PREFIX . "expedition SET";
     $sql .= " ref='" . $numref . "'";
     $sql .= ", fk_statut = 1";
     $sql .= ", date_valid = '" . $this->db->idate($now) . "'";
     $sql .= ", fk_user_valid = " . $user->id;
     $sql .= " WHERE rowid = " . $this->id;
     dol_syslog(get_class($this) . "::valid update expedition", LOG_DEBUG);
     $resql = $this->db->query($sql);
     if (!$resql) {
         $this->error = $this->db->lasterror();
         $error++;
     }
     // If stock increment is done on sending (recommanded choice)
     if (!$error && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
         require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php';
         $langs->load("agenda");
         // Loop on each product line to add a stock movement
         // TODO possibilite d'expedier a partir d'une propale ou autre origine
         $sql = "SELECT cd.fk_product, cd.subprice,";
         $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,";
         $sql .= " edb.rowid as edbrowid, edb.eatby, edb.sellby, edb.batch, edb.qty as edbqty, edb.fk_origin_stock";
         $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet as cd,";
         $sql .= " " . MAIN_DB_PREFIX . "expeditiondet as ed";
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "expeditiondet_batch as edb on edb.fk_expeditiondet = ed.rowid";
         $sql .= " WHERE ed.fk_expedition = " . $this->id;
         $sql .= " AND cd.rowid = ed.fk_origin_line";
         dol_syslog(get_class($this) . "::valid select details", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if ($resql) {
             $cpt = $this->db->num_rows($resql);
             for ($i = 0; $i < $cpt; $i++) {
                 $obj = $this->db->fetch_object($resql);
                 if (empty($obj->edbrowid)) {
                     $qty = $obj->qty;
                 } else {
                     $qty = $obj->edbqty;
                 }
                 if ($qty <= 0) {
                     continue;
                 }
                 dol_syslog(get_class($this) . "::valid movement index " . $i . " ed.rowid=" . $obj->rowid . " edb.rowid=" . $obj->edbrowid);
                 //var_dump($this->lines[$i]);
                 $mouvS = new MouvementStock($this->db);
                 $mouvS->origin =& $this;
                 if (empty($obj->edbrowid)) {
                     // line without batch detail
                     // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
                     $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref));
                     if ($result < 0) {
                         $error++;
                         break;
                     }
                 } else {
                     // line with batch detail
                     // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record
                     $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ShipmentValidatedInDolibarr", $numref), '', $obj->eatby, $obj->sellby, $obj->batch);
                     if ($result < 0) {
                         $error++;
                         break;
                     }
                     // We update content of table llx_product_batch (will be rename into llx_product_stock_batch inantoher version)
                     // We can set livraison_batch to deprecated and adapt livraison to handle batch too (mouvS->_create also calls mouvS->_create_batch)
                     if (!empty($conf->productbatch->enabled)) {
                         $result = $mouvS->livraison_batch($obj->fk_origin_stock, $qty);
                         // ->fk_origin_stock = id into table llx_product_batch (will be rename into llx_product_stock_batch in another version)
                         if ($result < 0) {
                             $error++;
                             $this->errors[] = $mouvS->error;
                             break;
                         }
                     }
                 }
             }
         } else {
             $this->db->rollback();
             $this->error = $this->db->error();
             return -2;
         }
     }
     if (!$error && !$notrigger) {
         // Call trigger
         $result = $this->call_trigger('SHIPPING_VALIDATE', $user);
         if ($result < 0) {
             $error++;
         }
         // End call triggers
     }
     if (!$error) {
         $this->oldref = $this->ref;
         // Rename directory if dir was a temporary ref
         if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
             // On renomme repertoire ($this->ref = ancienne ref, $numfa = nouvelle ref)
             // in order not to lose the attached files
             $oldref = dol_sanitizeFileName($this->ref);
             $newref = dol_sanitizeFileName($numref);
             $dirsource = $conf->expedition->dir_output . '/sending/' . $oldref;
             $dirdest = $conf->expedition->dir_output . '/sending/' . $newref;
             if (file_exists($dirsource)) {
                 dol_syslog(get_class($this) . "::valid rename dir " . $dirsource . " into " . $dirdest);
                 if (@rename($dirsource, $dirdest)) {
                     dol_syslog("Rename ok");
                     // Rename docs starting with $oldref with $newref
                     $listoffiles = dol_dir_list($conf->expedition->dir_output . '/sending/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/'));
                     foreach ($listoffiles as $fileentry) {
                         $dirsource = $fileentry['name'];
                         $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource);
                         $dirsource = $fileentry['path'] . '/' . $dirsource;
                         $dirdest = $fileentry['path'] . '/' . $dirdest;
                         @rename($dirsource, $dirdest);
                     }
                 }
             }
         }
     }
     // Set new ref and current status
     if (!$error) {
         $this->ref = $numref;
         $this->statut = 1;
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         foreach ($this->errors as $errmsg) {
             dol_syslog(get_class($this) . "::valid " . $errmsg, LOG_ERR);
             $this->error .= $this->error ? ', ' . $errmsg : $errmsg;
         }
         $this->db->rollback();
         return -1 * $error;
     }
 }
Ejemplo n.º 17
0
 /**
  * Tag invoice as validated + call trigger BILL_VALIDATE
  * Object must have lines loaded with fetch_lines
  *
  * @param	User	$user           Object user that validate
  * @param   string	$force_number	Reference to force on invoice
  * @param	int		$idwarehouse	Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
  * @param	int		$notrigger		1=Does not execute triggers, 0= execuete triggers
  * @return	int						<0 if KO, >0 if OK
  */
 function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0)
 {
     global $conf, $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $now = dol_now();
     $error = 0;
     dol_syslog(get_class($this) . '::validate user='******', force_number=' . $force_number . ', idwarehouse=' . $idwarehouse);
     // Check parameters
     if (!$this->brouillon) {
         dol_syslog(get_class($this) . "::validate no draft status", LOG_WARNING);
         return 0;
     }
     if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->creer) || !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->facture->invoice_advance->validate)) {
         $this->error = 'Permission denied';
         dol_syslog(get_class($this) . "::validate " . $this->error, LOG_ERR);
         return -1;
     }
     $this->db->begin();
     $this->fetch_thirdparty();
     $this->fetch_lines();
     // Check parameters
     if ($this->type == self::TYPE_REPLACEMENT) {
         // Controle que facture source connue
         if ($this->fk_facture_source <= 0) {
             $this->error = $langs->trans("ErrorFieldRequired", $langs->trans("InvoiceReplacement"));
             $this->db->rollback();
             return -10;
         }
         // Charge la facture source a remplacer
         $facreplaced = new Facture($this->db);
         $result = $facreplaced->fetch($this->fk_facture_source);
         if ($result <= 0) {
             $this->error = $langs->trans("ErrorBadInvoice");
             $this->db->rollback();
             return -11;
         }
         // Controle que facture source non deja remplacee par une autre
         $idreplacement = $facreplaced->getIdReplacingInvoice('validated');
         if ($idreplacement && $idreplacement != $this->id) {
             $facreplacement = new Facture($this->db);
             $facreplacement->fetch($idreplacement);
             $this->error = $langs->trans("ErrorInvoiceAlreadyReplaced", $facreplaced->ref, $facreplacement->ref);
             $this->db->rollback();
             return -12;
         }
         $result = $facreplaced->set_canceled($user, 'replaced', '');
         if ($result < 0) {
             $this->error = $facreplaced->error;
             $this->db->rollback();
             return -13;
         }
     }
     // Define new ref
     if ($force_number) {
         $num = $force_number;
     } else {
         if (preg_match('/^[\\(]?PROV/i', $this->ref) || empty($this->ref)) {
             if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
                 $this->date = dol_now();
                 $this->date_lim_reglement = $this->calculate_date_lim_reglement();
             }
             $num = $this->getNextNumRef($this->client);
         } else {
             $num = $this->ref;
         }
     }
     $this->newref = $num;
     if ($num) {
         $this->update_price(1);
         // Validate
         $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture';
         $sql .= " SET facnumber='" . $num . "', fk_statut = " . self::STATUS_VALIDATED . ", fk_user_valid = " . $user->id . ", date_valid = '" . $this->db->idate($now) . "'";
         if (!empty($conf->global->FAC_FORCE_DATE_VALIDATION)) {
             $sql .= ", datef='" . $this->db->idate($this->date) . "'";
             $sql .= ", date_lim_reglement='" . $this->db->idate($this->date_lim_reglement) . "'";
         }
         $sql .= ' WHERE rowid = ' . $this->id;
         dol_syslog(get_class($this) . "::validate", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             dol_print_error($this->db);
             $error++;
         }
         // On verifie si la facture etait une provisoire
         if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
             // La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne
         }
         if (!$error) {
             // Define third party as a customer
             $result = $this->client->set_as_client();
             // Si active on decremente le produit principal et ses composants a la validation de facture
             if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) {
                 require_once DOL_DOCUMENT_ROOT . '/product/stock/class/mouvementstock.class.php';
                 $langs->load("agenda");
                 // Loop on each line
                 $cpt = count($this->lines);
                 for ($i = 0; $i < $cpt; $i++) {
                     if ($this->lines[$i]->fk_product > 0) {
                         $mouvP = new MouvementStock($this->db);
                         $mouvP->origin =& $this;
                         // We decrease stock for product
                         if ($this->type == self::TYPE_CREDIT_NOTE) {
                             $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num));
                         } else {
                             $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
                         }
                         if ($result < 0) {
                             $error++;
                         }
                     }
                 }
             }
         }
         // Trigger calls
         if (!$error && !$notrigger) {
             // Call trigger
             $result = $this->call_trigger('BILL_VALIDATE', $user);
             if ($result < 0) {
                 $error++;
             }
             // End call triggers
         }
         if (!$error) {
             $this->oldref = $this->ref;
             // Rename directory if dir was a temporary ref
             if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
                 // Rename of object directory ($this->ref = old ref, $num = new ref)
                 // to  not lose the linked files
                 $oldref = dol_sanitizeFileName($this->ref);
                 $newref = dol_sanitizeFileName($num);
                 $dirsource = $conf->facture->dir_output . '/' . $oldref;
                 $dirdest = $conf->facture->dir_output . '/' . $newref;
                 if (file_exists($dirsource)) {
                     dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest);
                     if (@rename($dirsource, $dirdest)) {
                         dol_syslog("Rename ok");
                         // Rename docs starting with $oldref with $newref
                         $listoffiles = dol_dir_list($conf->facture->dir_output . '/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/'));
                         foreach ($listoffiles as $fileentry) {
                             $dirsource = $fileentry['name'];
                             $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource);
                             $dirsource = $fileentry['path'] . '/' . $dirsource;
                             $dirdest = $fileentry['path'] . '/' . $dirdest;
                             @rename($dirsource, $dirdest);
                         }
                     }
                 }
             }
         }
         // Set new ref and define current statut
         if (!$error) {
             $this->ref = $num;
             $this->facnumber = $num;
             $this->statut = self::STATUS_VALIDATED;
             $this->brouillon = 0;
             $this->date_validation = $now;
             $i = 0;
             $final = True;
             while ($i < count($this->lines) && $final == True) {
                 $final = $this->lines[$i]->situation_percent == 100;
                 $i++;
             }
             if ($final) {
                 $this->setFinal();
             }
         }
     } else {
         $error++;
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
Ejemplo n.º 18
0
}
// Remove directory
if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') {
    $result = $ecmdir->delete($user);
    setEventMessage($langs->trans("ECMSectionWasRemoved", $ecmdir->label));
    clearstatcache();
}
// Refresh directory view
if ($action == 'refreshmanual') {
    $ecmdirtmp = new EcmDirectory($db);
    // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
    clearstatcache();
    $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output);
    $diroutputslash .= '/';
    // Scan directory tree on disk
    $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0);
    // Scan directory tree in database
    $sqltree = $ecmdirstatic->get_full_arbo(0);
    $adirwascreated = 0;
    // Now we compare both trees to complete missing trees into database
    //var_dump($disktree);
    //var_dump($sqltree);
    foreach ($disktree as $dirdesc) {
        $dirisindatabase = 0;
        foreach ($sqltree as $dirsqldesc) {
            if ($conf->ecm->dir_output . '/' . $dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
                $dirisindatabase = 1;
                break;
            }
        }
        if (!$dirisindatabase) {
Ejemplo n.º 19
0
 /**
  * 	Parse file
  *
  * 	@return	void
  */
 private function parse_refLangTranslationFiles()
 {
     $files = $this->getTranslationFilesArray($this->_refLang);
     $counter = 1;
     foreach ($files as $file) {
         if ($this->_limittofile && $this->_limittofile != $file) {
             continue;
         }
         $counter++;
         $fileContent = null;
         $refPath = $this->_langDir . $this->_refLang . self::DIR_SEPARATOR . $file;
         $fileContent = file($refPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
         print "Processing file " . $file . ", with " . count($fileContent) . " lines<br>\n";
         // Define target dirs
         $targetlangs = array($this->_destlang);
         if ($this->_destlang == 'all') {
             $targetlangs = array();
             // If we must process all languages
             $arraytmp = dol_dir_list($this->_langDir, 'directories', 0);
             foreach ($arraytmp as $dirtmp) {
                 if ($dirtmp['name'] === $this->_refLang) {
                     continue;
                 }
                 // We discard source language
                 $tmppart = explode('_', $dirtmp['name']);
                 if (preg_match('/^en/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard en_* languages
                 if (preg_match('/^fr/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard fr_* languages
                 if (preg_match('/^es/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard es_* languages
                 if (preg_match('/ca_ES/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard es_CA language
                 if (preg_match('/pt_BR/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard pt_BR language
                 if (preg_match('/nl_BE/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard nl_BE language
                 if (preg_match('/^\\./i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard files .*
                 if (preg_match('/^CVS/i', $dirtmp['name'])) {
                     continue;
                 }
                 // We discard CVS
                 $targetlangs[] = $dirtmp['name'];
             }
             //var_dump($targetlangs);
         }
         // Process translation of source file for each target languages
         foreach ($targetlangs as $my_destlang) {
             $this->_translatedFiles = array();
             $destPath = $this->_langDir . $my_destlang . self::DIR_SEPARATOR . $file;
             // Check destination file presence
             if (!file_exists($destPath)) {
                 // No file present, we generate file
                 echo "File not found: " . $destPath . ". We generate it.<br>\n";
                 $this->createTranslationFile($destPath, $my_destlang);
             } else {
                 echo "Updating file: " . $destPath . "<br>\n";
             }
             // Translate lines
             $fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
             $newlines = 0;
             foreach ($fileContent as $line) {
                 $key = $this->getLineKey($line);
                 $value = $this->getLineValue($line);
                 if ($key && $value) {
                     $newlines += $this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang);
                 }
             }
             $this->updateTranslationFile($destPath, $file, $my_destlang);
             echo "New translated lines: " . $newlines . "<br>\n";
             //if ($counter ==3) die('fim');
         }
     }
 }
Ejemplo n.º 20
0
/**
 * 	Return list of activated modules usable for document generation
 *
 * 	@param	DoliDB		$db				    Database handler
 * 	@param	string		$type			    Type of models (company, invoice, ...)
 *  @param  int		    $maxfilenamelength  Max length of value to show
 * 	@return	mixed			    			0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename".
 */
function getListOfModels($db, $type, $maxfilenamelength = 0)
{
    global $conf, $langs;
    $liste = array();
    $found = 0;
    $dirtoscan = '';
    $sql = "SELECT nom as id, nom as lib, libelle as label, description as description";
    $sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
    $sql .= " WHERE type = '" . $type . "'";
    $sql .= " AND entity in (0," . $conf->entity . ")";
    //print $sql;
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        while ($i < $num) {
            $found = 1;
            $obj = $db->fetch_object($resql);
            // If this generation module needs to scan a directory, then description field is filled
            // with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
            if (!empty($obj->description)) {
                include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
                $const = $obj->description;
                $dirtoscan .= ($dirtoscan ? ',' : '') . preg_replace('/[\\r\\n]+/', ',', trim($conf->global->{$const}));
                $listoffiles = array();
                // Now we add models found in directories scanned
                $listofdir = explode(',', $dirtoscan);
                foreach ($listofdir as $key => $tmpdir) {
                    $tmpdir = trim($tmpdir);
                    if ($conf->multicompany->enabled && $conf->entity > 1) {
                        $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT . "/" . $conf->entity, $tmpdir);
                    } else {
                        $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
                    }
                    if (!$tmpdir) {
                        unset($listofdir[$key]);
                        continue;
                    }
                    if (is_dir($tmpdir)) {
                        $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.odt');
                        if (count($tmpfiles)) {
                            $listoffiles = array_merge($listoffiles, $tmpfiles);
                        }
                    }
                }
                if (count($listoffiles)) {
                    foreach ($listoffiles as $record) {
                        $max = $maxfilenamelength ? $maxfilenamelength : 28;
                        $liste[$obj->id . ':' . $record['fullname']] = dol_trunc($record['name'], $max, 'middle');
                    }
                } else {
                    $liste[0] = $obj->label . ': ' . $langs->trans("None");
                }
            } else {
                $liste[$obj->id] = $obj->label ? $obj->label : $obj->lib;
            }
            $i++;
        }
    } else {
        dol_print_error($db);
        return -1;
    }
    if ($found) {
        return $liste;
    } else {
        return 0;
    }
}
Ejemplo n.º 21
0
 /**
  *  Set status to validated
  *
  *  @param	User	$user       Object user that validate
  *  @param	int		$notrigger	1=Does not execute triggers, 0= execuete triggers
  *  @return int         		<0 if KO, >=0 if OK
  */
 function valid($user, $notrigger = 0)
 {
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     global $conf, $langs;
     $error = 0;
     $now = dol_now();
     if ($user->rights->propale->valider) {
         $this->db->begin();
         // Numbering module definition
         $soc = new Societe($this->db);
         $soc->fetch($this->socid);
         // Define new ref
         if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
             $num = $this->getNextNumRef($soc);
         } else {
             $num = $this->ref;
         }
         $this->newref = $num;
         $sql = "UPDATE " . MAIN_DB_PREFIX . "propal";
         $sql .= " SET ref = '" . $num . "',";
         $sql .= " fk_statut = 1, date_valid='" . $this->db->idate($now) . "', fk_user_valid=" . $user->id;
         $sql .= " WHERE rowid = " . $this->id . " AND fk_statut = 0";
         dol_syslog(get_class($this) . "::valid", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             dol_print_error($this->db);
             $error++;
         }
         // Trigger calls
         if (!$error && !$notrigger) {
             // Call trigger
             $result = $this->call_trigger('PROPAL_VALIDATE', $user);
             if ($result < 0) {
                 $error++;
             }
             // End call triggers
         }
         if (!$error) {
             $this->oldref = $this->ref;
             // Rename directory if dir was a temporary ref
             if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
                 // Rename of propal directory ($this->ref = old ref, $num = new ref)
                 // to  not lose the linked files
                 $oldref = dol_sanitizeFileName($this->ref);
                 $newref = dol_sanitizeFileName($num);
                 $dirsource = $conf->propal->dir_output . '/' . $oldref;
                 $dirdest = $conf->propal->dir_output . '/' . $newref;
                 if (file_exists($dirsource)) {
                     dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest);
                     if (@rename($dirsource, $dirdest)) {
                         dol_syslog("Rename ok");
                         // Rename docs starting with $oldref with $newref
                         $listoffiles = dol_dir_list($conf->propal->dir_output . '/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/'));
                         foreach ($listoffiles as $fileentry) {
                             $dirsource = $fileentry['name'];
                             $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource);
                             $dirsource = $fileentry['path'] . '/' . $dirsource;
                             $dirdest = $fileentry['path'] . '/' . $dirdest;
                             @rename($dirsource, $dirdest);
                         }
                     }
                 }
             }
             $this->ref = $num;
             $this->brouillon = 0;
             $this->statut = 1;
             $this->user_valid_id = $user->id;
             $this->datev = $now;
             $this->db->commit();
             return 1;
         } else {
             $this->db->rollback();
             return -1;
         }
     }
 }
        }
    }
    if (in_array($module, $automodules)) {
        $param .= '&module=' . $module;
        $textifempty = $section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"));
        $filearray = dol_dir_list($upload_dir, "files", 1, '', $excludefiles, $sortfield, $sorting, 1);
        $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $user->rights->ecm->upload, 1, $textifempty, $maxlengthname, $url);
    } else {
        $relativepath = $ecmdir->getRelativePath();
        $upload_dir = $conf->ecm->dir_output . '/' . $relativepath;
        // If $section defined with value 0
        if ($section === '0') {
            $filearray = array();
            $textifempty = '<br><div align="center"><font class="warning">' . $langs->trans("DirNotSynchronizedSyncFirst") . '</font></div><br>';
        } else {
            $filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\\.', '(\\.meta|_preview\\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
        }
        if ($section) {
            $param .= '&section=' . $section;
            $textifempty = $langs->trans('NoFileFound');
        } else {
            $textifempty = $showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection");
        }
        $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty, $maxlengthname, '', $url);
    }
}
if ($section) {
    $useajax = 1;
    if (!empty($conf->dol_use_jmobile)) {
        $useajax = 0;
    }
Ejemplo n.º 23
0
 /**	Load an object from its id and create a new one in database
  *
  *	@param	int		$fromid     			Id of object to clone
  *  @param	int		$project_id				Id of project to attach clone task
  *  @param	int		$parent_task_id			Id of task to attach clone task
  *  @param	bool	$clone_change_dt		recalculate date of task regarding new project start date
  *	@param	bool	$clone_affectation		clone affectation of project
  *	@param	bool	$clone_time				clone time of project
  *	@param	bool	$clone_file				clone file of project
  *  @param	bool	$clone_note				clone note of project
  *	@param	bool	$clone_prog				clone progress of project
  * 	@return	int								New id of clone
  */
 function createFromClone($fromid, $project_id, $parent_task_id, $clone_change_dt = false, $clone_affectation = false, $clone_time = false, $clone_file = false, $clone_note = false, $clone_prog = false)
 {
     global $user, $langs, $conf;
     $error = 0;
     //Use 00:00 of today if time is use on task.
     $now = dol_mktime(0, 0, 0, dol_print_date(dol_now(), '%m'), dol_print_date(dol_now(), '%d'), dol_print_date(dol_now(), '%Y'));
     $datec = $now;
     $clone_task = new Task($this->db);
     $origin_task = new Task($this->db);
     $clone_task->context['createfromclone'] = 'createfromclone';
     $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 = $origin_task->planned_workload;
     $clone_task->rang = $origin_task->rang;
     //Manage Task Date
     if ($clone_change_dt) {
         $projectstatic = new Project($this->db);
         $projectstatic->fetch($ori_project_id);
         //Origin project strat date
         $orign_project_dt_start = $projectstatic->date_start;
         //Calcultate new task start date with difference between origin proj start date and origin task start date
         if (!empty($clone_task->date_start)) {
             $clone_task->date_start = $now + $clone_task->date_start - $orign_project_dt_start;
         }
         //Calcultate new task end date with difference between origin proj end date and origin task end date
         if (!empty($clone_task->date_end)) {
             $clone_task->date_end = $now + $clone_task->date_end - $orign_project_dt_start;
         }
     }
     if (!$clone_prog) {
         $clone_task->progress = 0;
     }
     // Create clone
     $result = $clone_task->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $clone_task->error;
         $error++;
     }
     // End
     if (!$error) {
         $clone_task_id = $clone_task->id;
         $clone_task_ref = $clone_task->ref;
         //Note Update
         if (!$clone_note) {
             $clone_task->note_private = '';
             $clone_task->note_public = '';
         } else {
             $this->db->begin();
             $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_public, ENT_QUOTES), '_public');
             if ($res < 0) {
                 $this->error .= $clone_task->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
             $this->db->begin();
             $res = $clone_task->update_note(dol_html_entity_decode($clone_task->note_private, ENT_QUOTES), '_private');
             if ($res < 0) {
                 $this->error .= $clone_task->error;
                 $error++;
                 $this->db->rollback();
             } else {
                 $this->db->commit();
             }
         }
         //Duplicate file
         if ($clone_file) {
             require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
             //retreive project origin ref to know folder to copy
             $projectstatic = new Project($this->db);
             $projectstatic->fetch($ori_project_id);
             $ori_project_ref = $projectstatic->ref;
             if ($ori_project_id != $project_id) {
                 $projectstatic->fetch($project_id);
                 $clone_project_ref = $projectstatic->ref;
             } else {
                 $clone_project_ref = $ori_project_ref;
             }
             $clone_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($clone_project_ref) . "/" . dol_sanitizeFileName($clone_task_ref);
             $ori_task_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($ori_project_ref) . "/" . dol_sanitizeFileName($fromid);
             $filearray = dol_dir_list($ori_task_dir, "files", 0, '', '(\\.meta|_preview\\.png)$', '', SORT_ASC, 1);
             foreach ($filearray as $key => $file) {
                 if (!file_exists($clone_task_dir)) {
                     if (dol_mkdir($clone_task_dir) < 0) {
                         $this->error .= $langs->trans('ErrorInternalErrorDetected') . ':dol_mkdir';
                         $error++;
                     }
                 }
                 $rescopy = dol_copy($ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name'], 0, 1);
                 if (is_numeric($rescopy) && $rescopy < 0) {
                     $this->error .= $langs->trans("ErrorFailToCopyFile", $ori_task_dir . '/' . $file['name'], $clone_task_dir . '/' . $file['name']);
                     $error++;
                 }
             }
         }
         // clone affectation
         if ($clone_affectation) {
             $origin_task = new Task($this->db);
             $origin_task->fetch($fromid);
             foreach (array('internal', 'external') as $source) {
                 $tab = $origin_task->liste_contact(-1, $source);
                 $num = count($tab);
                 $i = 0;
                 while ($i < $num) {
                     $clone_task->add_contact($tab[$i]['id'], $tab[$i]['code'], $tab[$i]['source']);
                     if ($clone_task->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
                         $langs->load("errors");
                         $this->error .= $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
                         $error++;
                     } else {
                         if ($clone_task->error != '') {
                             $this->error .= $clone_task->error;
                             $error++;
                         }
                     }
                     $i++;
                 }
             }
         }
         if ($clone_time) {
             //TODO clone time of affectation
         }
     }
     unset($clone_task->context['createfromclone']);
     if (!$error) {
         $this->db->commit();
         return $clone_task_id;
     } else {
         $this->db->rollback();
         dol_syslog(get_class($this) . "::createFromClone nbError: " . $error . " error : " . $this->error, LOG_ERR);
         return -1;
     }
 }
Ejemplo n.º 24
0
 /**
  *	Show only Document icon with link
  *
  *	@param	string	$modulepart		propal, facture, facture_fourn, ...
  *	@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	$filter			Filter filenames on this regex string (Example: '\.pdf$')
  *	@return	string              	Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles
  */
 function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '')
 {
     include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $out = '';
     $this->infofiles = array('nboffiles' => 0, 'extensions' => array(), 'files' => array());
     $file_list = dol_dir_list($filedir, 'files', 0, preg_quote(basename($modulesubdir), '/') . '[^\\-]+', '\\.meta$|\\.png$');
     // Get list of files starting with name fo ref (but not followed by "-" to discard uploaded files)
     // For ajax treatment
     $out .= '<div id="gen_pdf_' . $modulesubdir . '" class="linkobject hideobject">' . img_picto('', 'refresh') . '</div>' . "\n";
     if (!empty($file_list)) {
         // Loop on each file found
         foreach ($file_list as $file) {
             if ($filter && !preg_match('/' . $filter . '/i', $file["name"])) {
                 continue;
             }
             // Discard this. It does not match provided filter.
             // Define relative path for download link (depends on module)
             $relativepath = $file["name"];
             // Cas general
             if ($modulesubdir) {
                 $relativepath = $modulesubdir . "/" . $file["name"];
             }
             // Cas propal, facture...
             // Autre cas
             if ($modulepart == 'donation') {
                 $relativepath = get_exdir($modulesubdir, 2, 0, 0, null, 'donation') . $file["name"];
             }
             if ($modulepart == 'export') {
                 $relativepath = $file["name"];
             }
             if ($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_fournisseur') {
                 $relativepath = get_exdir($modulesubdir, 2, 0, 0, null, 'invoice_supplier') . $modulesubdir . "/" . $file["name"];
             }
             // Show file name with link to download
             $out .= '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&amp;file=' . urlencode($relativepath) . '"';
             $mime = dol_mimetype($relativepath, '', 0);
             if (preg_match('/text/', $mime)) {
                 $out .= ' target="_blank"';
             }
             $out .= '>';
             $out .= img_mime($relativepath, $file["name"]);
             $out .= '</a>' . "\n";
             $this->infofiles['nboffiles']++;
             $this->infofiles['files'][] = $file['fullname'];
             $ext = pathinfo($file["name"], PATHINFO_EXTENSION);
             if (empty($this->infofiles[$ext])) {
                 $this->infofiles['extensions'][$ext] = 1;
             } else {
                 $this->infofiles['extensions'][$ext]++;
             }
         }
     }
     return $out;
 }
Ejemplo n.º 25
0
    if (!in_array($basedir, $listdir)) {
        print img_warning($langs->trans('WarningSafeModeOnCheckExecDir'));
        dol_syslog("safe_mode is on, basedir is " . $basedir . ", safe_mode_exec_dir is " . ini_get('safe_mode_exec_dir'), LOG_WARNING);
    }
}
print '<input type="text" name="MAIN_ANTIVIRUS_COMMAND" size="72" value="' . (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? dol_htmlentities($conf->global->MAIN_ANTIVIRUS_COMMAND) : '') . '">';
print "</td>";
print '</tr>';
// Use anti virus
$var = !$var;
print "<tr " . $bc[$var] . ">";
print '<td colspan="2">' . $langs->trans("AntiVirusParam") . '<br>';
print $langs->trans("AntiVirusParamExample");
print '</td>';
print '<td>';
print '<input type="text" name="MAIN_ANTIVIRUS_PARAM" size="72" value="' . (!empty($conf->global->MAIN_ANTIVIRUS_PARAM) ? dol_htmlentities($conf->global->MAIN_ANTIVIRUS_PARAM) : '') . '">';
print "</td>";
print '</tr>';
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="button" value="' . $langs->trans("Modify") . '"></div>';
print '</form>';
// Form to test upload
print '<br>';
$formfile = new FormFile($db);
$formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestFileUploadForm"), 0, 0, 1, 50, '', '', 1, '', 0);
// List of document
$filearray = dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
$formfile->list_of_documents($filearray, '', 'admin_temp', '');
llxFooter();
$db->close();
 /**
  *	Validate an order
  *
  *	@param	User	$user			Validator User
  *	@param	int		$idwarehouse	Id of warehouse to use for stock decrease
  *  @param	int		$notrigger		1=Does not execute triggers, 0= execuete triggers
  *	@return	int						<0 if KO, >0 if OK
  */
 function valid($user, $idwarehouse = 0, $notrigger = 0)
 {
     global $langs, $conf;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $error = 0;
     dol_syslog(get_class($this) . "::valid");
     $result = 0;
     if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->commande->creer) || !empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_order_advance->validate)) {
         $this->db->begin();
         // Definition du nom de modele de numerotation de commande
         $soc = new Societe($this->db);
         $soc->fetch($this->fourn_id);
         // Check if object has a temporary ref
         if (preg_match('/^[\\(]?PROV/i', $this->ref) || empty($this->ref)) {
             $num = $this->getNextNumRef($soc);
         } else {
             $num = $this->ref;
         }
         $this->newref = $num;
         $sql = 'UPDATE ' . MAIN_DB_PREFIX . "commande_fournisseur";
         $sql .= " SET ref='" . $this->db->escape($num) . "',";
         $sql .= " fk_statut = 1,";
         $sql .= " date_valid='" . $this->db->idate(dol_now()) . "',";
         $sql .= " fk_user_valid = " . $user->id;
         $sql .= " WHERE rowid = " . $this->id;
         $sql .= " AND fk_statut = 0";
         $resql = $this->db->query($sql);
         if (!$resql) {
             dol_print_error($this->db);
             $error++;
         }
         if (!$error && !$notrigger) {
             // Call trigger
             $result = $this->call_trigger('ORDER_SUPPLIER_VALIDATE', $user);
             if ($result < 0) {
                 $error++;
             }
             // End call triggers
         }
         if (!$error) {
             $this->oldref = $this->ref;
             // Rename directory if dir was a temporary ref
             if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
                 // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
                 // in order not to lose the attached files
                 $oldref = dol_sanitizeFileName($this->ref);
                 $newref = dol_sanitizeFileName($num);
                 $dirsource = $conf->fournisseur->dir_output . '/commande/' . $oldref;
                 $dirdest = $conf->fournisseur->dir_output . '/commande/' . $newref;
                 if (file_exists($dirsource)) {
                     dol_syslog(get_class($this) . "::valid rename dir " . $dirsource . " into " . $dirdest);
                     if (@rename($dirsource, $dirdest)) {
                         dol_syslog("Rename ok");
                         // Rename docs starting with $oldref with $newref
                         $listoffiles = dol_dir_list($conf->fournisseur->dir_output . '/commande/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/'));
                         foreach ($listoffiles as $fileentry) {
                             $dirsource = $fileentry['name'];
                             $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource);
                             $dirsource = $fileentry['path'] . '/' . $dirsource;
                             $dirdest = $fileentry['path'] . '/' . $dirdest;
                             @rename($dirsource, $dirdest);
                         }
                     }
                 }
             }
         }
         if (!$error) {
             $result = 1;
             $this->log($user, 1, time());
             // Statut 1
             $this->statut = 1;
             $this->ref = $num;
         }
         if (!$error) {
             $this->db->commit();
             return 1;
         } else {
             $this->db->rollback();
             return -1;
         }
     } else {
         $this->error = 'NotAuthorized';
         dol_syslog(get_class($this) . "::valid " . $this->error, LOG_ERR);
         return -1;
     }
 }
Ejemplo n.º 27
0
/**
 *  Return array head with list of tabs to view object informations
 *
 *  @param	Adherent	$object         Member
 *  @return array           		head
 */
function member_prepare_head(Adherent $object)
{
    global $db, $langs, $conf, $user;
    $h = 0;
    $head = array();
    $head[$h][0] = DOL_URL_ROOT . '/adherents/card.php?rowid=' . $object->id;
    $head[$h][1] = $langs->trans("MemberCard");
    $head[$h][2] = 'general';
    $h++;
    if (!empty($conf->ldap->enabled) && !empty($conf->global->LDAP_MEMBER_ACTIVE)) {
        $langs->load("ldap");
        $head[$h][0] = DOL_URL_ROOT . '/adherents/ldap.php?id=' . $object->id;
        $head[$h][1] = $langs->trans("LDAPCard");
        $head[$h][2] = 'ldap';
        $h++;
    }
    if (!empty($user->rights->adherent->cotisation->lire)) {
        $head[$h][0] = DOL_URL_ROOT . '/adherents/card_subscriptions.php?rowid=' . $object->id;
        $head[$h][1] = $langs->trans("Subscriptions");
        $head[$h][2] = 'subscription';
        $h++;
    }
    // Show agenda tab
    if (!empty($conf->agenda->enabled)) {
        $head[$h][0] = DOL_URL_ROOT . "/adherents/agenda.php?id=" . $object->id;
        $head[$h][1] = $langs->trans('Agenda');
        $head[$h][2] = 'agenda';
        $h++;
    }
    // Show more tabs from modules
    // Entries must be declared in modules descriptor with line
    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
    $nbNote = 0;
    if (!empty($object->note)) {
        $nbNote++;
    }
    if (!empty($object->note_private)) {
        $nbNote++;
    }
    if (!empty($object->note_public)) {
        $nbNote++;
    }
    $head[$h][0] = DOL_URL_ROOT . '/adherents/note.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Note");
    $head[$h][2] = 'note';
    if ($nbNote > 0) {
        $head[$h][1] .= ' <span class="badge">' . $nbNote . '</span>';
    }
    $h++;
    // Attachments
    require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php';
    $upload_dir = $conf->adherent->multidir_output[$object->entity] . '/' . get_exdir($object->id, 2, 0, 1, $object, 'member') . '/' . dol_sanitizeFileName($object->ref);
    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\\.meta|_preview\\.png)$'));
    $nbLinks = Link::count($db, $object->element, $object->id);
    $head[$h][0] = DOL_URL_ROOT . '/adherents/document.php?id=' . $object->id;
    $head[$h][1] = $langs->trans('Documents');
    if ($nbFiles + $nbLinks > 0) {
        $head[$h][1] .= ' <span class="badge">' . ($nbFiles + $nbLinks) . '</span>';
    }
    $head[$h][2] = 'documents';
    $h++;
    $head[$h][0] = DOL_URL_ROOT . '/adherents/info.php?id=' . $object->id;
    $head[$h][1] = $langs->trans("Info");
    $head[$h][2] = 'info';
    $h++;
    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
    return $head;
}
 /**
  * Return description of a module
  *
  * @param	Translate	$langs		Object language
  * @return	string      			Description
  */
 function info($langs)
 {
     global $conf, $langs;
     $langs->load("companies");
     $langs->load("errors");
     $form = new Form($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="setModuleOptions">';
     $texte .= '<input type="hidden" name="param1" value="COMPANY_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->COMPANY_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->COMPANY_ADDON_PDF_ODT_PATH;
     $texte .= '</textarea>';
     $texte .= '</td>';
     $texte .= '<td align="center">&nbsp; ';
     $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><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;
 }
Ejemplo n.º 29
0
        }
    }
}
/*
 * View
 */
llxHeader();
$form = new Form($db);
if ($id > 0 || !empty($ref)) {
    if ($object->fetch($id, $ref)) {
        $upload_dir = $conf->bank->dir_output . '/' . $object->ref;
        // Onglets
        $head = bank_prepare_head($object);
        dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), 0, 'account');
        // Construit liste des fichiers
        $filearray = dol_dir_list($upload_dir, "files", 0, '', '\\.meta$', $sortfield, strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC, 1);
        $totalsize = 0;
        foreach ($filearray as $key => $file) {
            $totalsize += $file['size'];
        }
        print '<table class="border"width="100%">';
        // Ref
        // Ref
        print '<tr><td valign="top" width="25%">' . $langs->trans("Ref") . '</td>';
        print '<td colspan="3">';
        print $form->showrefnav($object, 'ref', '', 1, 'ref');
        print '</td></tr>';
        // Label
        print '<tr><td valign="top">' . $langs->trans("Label") . '</td>';
        print '<td colspan="3">' . $object->label . '</td></tr>';
        // Status
Ejemplo n.º 30
0
 /**
  * Validate a contract
  *
  * @param	User	$user      		Objet User
  * @param   string	$force_number	Reference to force on contract (not implemented yet)
  * @param	int		$notrigger		1=Does not execute triggers, 0= execuete triggers
  * @return	int						<0 if KO, >0 if OK
  */
 function validate($user, $force_number = '', $notrigger = 0)
 {
     require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     global $langs, $conf;
     $now = dol_now();
     $error = 0;
     dol_syslog(get_class($this) . '::validate user='******', force_number=' . $force_number);
     $this->db->begin();
     $this->fetch_thirdparty();
     // A contract is validated so we can move thirdparty to status customer
     $result = $this->thirdparty->set_as_client();
     // Define new ref
     if (!$error && preg_match('/^[\\(]?PROV/i', $this->ref)) {
         $num = $this->getNextNumRef($this->thirdparty);
     } else {
         $num = $this->ref;
     }
     $this->newref = $num;
     if ($num) {
         $sql = "UPDATE " . MAIN_DB_PREFIX . "contrat SET ref = '" . $num . "', statut = 1";
         //$sql.= ", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'";
         $sql .= " WHERE rowid = " . $this->id . " AND statut = 0";
         dol_syslog(get_class($this) . "::validate", LOG_DEBUG);
         $resql = $this->db->query($sql);
         if (!$resql) {
             dol_print_error($this->db);
             $error++;
             $this->error = $this->db->lasterror();
         }
         // Trigger calls
         if (!$error && !$notrigger) {
             // Call trigger
             $result = $this->call_trigger('CONTRACT_VALIDATE', $user);
             if ($result < 0) {
                 $error++;
             }
             // End call triggers
         }
         if (!$error) {
             $this->oldref = $this->ref;
             // Rename directory if dir was a temporary ref
             if (preg_match('/^[\\(]?PROV/i', $this->ref)) {
                 // Rename of object directory ($this->ref = old ref, $num = new ref)
                 // to  not lose the linked files
                 $oldref = dol_sanitizeFileName($this->ref);
                 $newref = dol_sanitizeFileName($num);
                 $dirsource = $conf->contract->dir_output . '/' . $oldref;
                 $dirdest = $conf->contract->dir_output . '/' . $newref;
                 if (file_exists($dirsource)) {
                     dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest);
                     if (@rename($dirsource, $dirdest)) {
                         dol_syslog("Rename ok");
                         // Rename docs starting with $oldref with $newref
                         $listoffiles = dol_dir_list($conf->contract->dir_output . '/' . $newref, 'files', 1, '^' . preg_quote($oldref, '/'));
                         foreach ($listoffiles as $fileentry) {
                             $dirsource = $fileentry['name'];
                             $dirdest = preg_replace('/^' . preg_quote($oldref, '/') . '/', $newref, $dirsource);
                             $dirsource = $fileentry['path'] . '/' . $dirsource;
                             $dirdest = $fileentry['path'] . '/' . $dirdest;
                             @rename($dirsource, $dirdest);
                         }
                     }
                 }
             }
         }
         // Set new ref and define current statut
         if (!$error) {
             $this->ref = $num;
             $this->statut = 1;
             $this->brouillon = 0;
             $this->date_validation = $now;
         }
     } else {
         $error++;
     }
     if (!$error) {
         $this->db->commit();
         return 1;
     } else {
         $this->db->rollback();
         return -1;
     }
 }