Ejemplo n.º 1
0
    public function getLoginPageOptions($parameters, &$object, &$action, HookManager $hookManager)
    {
        global $langs;
        require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
        require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
        $langs->load('otp@otp');
        if (versioncompare(versiondolibarrarray(), array('3', '8', '0')) >= 0) {
            $this->results = array('options' => array('table' => '<tr>
<td class="nowrap center valignmiddle"><input type="text" name="otp" class="flat" size="20" id="otp" tabindex="3" placeholder="' . $langs->trans('OTPCode') . '"></td></tr>'));
        } else {
            $this->results = array('options' => array('table' => '<tr>
<td>
<label for="otp"><strong>' . $langs->trans('OTPCode') . '</strong></label></td><td><input type="text" name="otp" class="flat" size="15" id="otp" tabindex="3"></td></tr>'));
        }
    }
Ejemplo n.º 2
0
 }
 // If a database access is available, we set more variable
 if ($ok) {
     if (empty($dolibarr_main_db_encryption)) {
         $dolibarr_main_db_encryption = 0;
     }
     $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
     if (empty($dolibarr_main_db_cryptkey)) {
         $dolibarr_main_db_cryptkey = '';
     }
     $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
     $conf->setValues($db);
     // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
     // Version to install is DOL_VERSION
     $dolibarrlastupgradeversionarray = preg_split('/[\\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : ''));
     $dolibarrversiontoinstallarray = versiondolibarrarray();
 }
 // Show title
 if (!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || !empty($conf->global->MAIN_VERSION_LAST_INSTALL)) {
     print $langs->trans("VersionLastUpgrade") . ': <b><font class="ok">' . (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_INSTALL : $conf->global->MAIN_VERSION_LAST_UPGRADE) . '</font></b><br>';
     print $langs->trans("VersionProgram") . ': <b><font class="ok">' . DOL_VERSION . '</font></b>';
     //print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired"));
     print '<br>';
     print '<br>';
 } else {
     print "<br>\n";
 }
 print $langs->trans("InstallEasy") . " ";
 print $langs->trans("ChooseYourSetupMode");
 print '<br /><br />';
 $foundrecommandedchoice = 0;
Ejemplo n.º 3
0
/**
 *  Enable a module
 *  @param      value       Name of module to activate
 *  @param      withdeps    Activate/Disable also all dependencies
 *  @return     string      Error message or '';
 */
function Activate($value,$withdeps=1)
{
    global $db, $modules, $langs, $conf;

    $modName = $value;

    $ret='';

    // Activate module
    if ($modName)
    {
        $modFile = $modName . ".class.php";

        // Loop on each directory
        $found=false;
    	foreach ($conf->file->dol_document_root as $type => $dirroot)
        {
            $modulesdir[] = $dirroot."/includes/modules/";
            
            if ($type == 'alt')
			{	
				$handle=@opendir($dirroot);
				if (is_resource($handle))
				{
					while (($file = readdir($handle))!==false)
					{
					    if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
					    {
					    	if (is_dir($dirroot . '/' . $file . '/includes/modules/'))
					    	{
					    		$modulesdir[] = $dirroot . '/' . $file . '/includes/modules/';
					    	}
					    }
					}
					closedir($handle);
				}
			}
        }

        foreach ($modulesdir as $dir)
        {
        	if (file_exists($dir.$modFile))
        	{
        		$found=@include_once($dir.$modFile);
        		if ($found) break;
        	}
        }

        $objMod = new $modName($db);

        // Test if PHP version ok
        $verphp=versionphparray();
        $vermin=isset($objMod->phpmin)?$objMod->phpmin:0;
        if (is_array($vermin) && versioncompare($verphp,$vermin) < 0)
        {
            return $langs->trans("ErrorModuleRequirePHPVersion",versiontostring($vermin));
        }

        // Test if Dolibarr version ok
        $verdol=versiondolibarrarray();
        $vermin=isset($objMod->need_dolibarr_version)?$objMod->need_dolibarr_version:0;
        //print 'eee'.versioncompare($verdol,$vermin).join(',',$verdol).' - '.join(',',$vermin);exit;
        if (is_array($vermin) && versioncompare($verdol,$vermin) < 0)
        {
            return $langs->trans("ErrorModuleRequireDolibarrVersion",versiontostring($vermin));
        }

        // Test if javascript requirement ok
        if (! empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax))
        {
            return $langs->trans("ErrorModuleRequireJavascript");
        }

        $result=$objMod->init();
        if ($result <= 0) $ret=$objMod->error;
    }

    if (! $ret && $withdeps)
    {
        if (is_array($objMod->depends) && !empty($objMod->depends))
        {
            // Activation des modules dont le module depend
            for ($i = 0; $i < sizeof($objMod->depends); $i++)
            {
                if (file_exists(DOL_DOCUMENT_ROOT."/includes/modules/".$objMod->depends[$i].".class.php"))
                {
                    Activate($objMod->depends[$i]);
                }
            }
        }

        if (isset($objMod->conflictwith) && is_array($objMod->conflictwith))
        {
            // Desactivation des modules qui entrent en conflit
            for ($i = 0; $i < sizeof($objMod->conflictwith); $i++)
            {
                if (file_exists(DOL_DOCUMENT_ROOT."/includes/modules/".$objMod->conflictwith[$i].".class.php"))
                {
                    UnActivate($objMod->conflictwith[$i],0);
                }
            }
        }
    }

    return $ret;
}
Ejemplo n.º 4
0
/**
 *  Enable a module
 *
 *  @param      string		$value      Name of module to activate
 *  @param      int			$withdeps   Activate/Disable also all dependencies
 *  @return     string      			Error message or '';
 */
function activateModule($value, $withdeps = 1)
{
    global $db, $modules, $langs, $conf;
    // Check parameters
    if (empty($value)) {
        return 'ErrorBadParameter';
    }
    $ret = '';
    $modName = $value;
    $modFile = $modName . ".class.php";
    // Loop on each directory to fill $modulesdir
    $modulesdir = dolGetModulesDirs();
    // Loop on each modulesdir directories
    $found = false;
    foreach ($modulesdir as $dir) {
        if (file_exists($dir . $modFile)) {
            $found = @(include_once $dir . $modFile);
            if ($found) {
                break;
            }
        }
    }
    $objMod = new $modName($db);
    // Test if PHP version ok
    $verphp = versionphparray();
    $vermin = isset($objMod->phpmin) ? $objMod->phpmin : 0;
    if (is_array($vermin) && versioncompare($verphp, $vermin) < 0) {
        return $langs->trans("ErrorModuleRequirePHPVersion", versiontostring($vermin));
    }
    // Test if Dolibarr version ok
    $verdol = versiondolibarrarray();
    $vermin = isset($objMod->need_dolibarr_version) ? $objMod->need_dolibarr_version : 0;
    //print 'eee '.versioncompare($verdol,$vermin).' - '.join(',',$verdol).' - '.join(',',$vermin);exit;
    if (is_array($vermin) && versioncompare($verdol, $vermin) < 0) {
        return $langs->trans("ErrorModuleRequireDolibarrVersion", versiontostring($vermin));
    }
    // Test if javascript requirement ok
    if (!empty($objMod->need_javascript_ajax) && empty($conf->use_javascript_ajax)) {
        return $langs->trans("ErrorModuleRequireJavascript");
    }
    $result = $objMod->init();
    if ($result <= 0) {
        $ret = $objMod->error;
    }
    if (!$ret && $withdeps) {
        if (isset($objMod->depends) && is_array($objMod->depends) && !empty($objMod->depends)) {
            // Activation des modules dont le module depend
            $num = count($objMod->depends);
            for ($i = 0; $i < $num; $i++) {
                foreach ($modulesdir as $dir) {
                    if (file_exists($dir . $objMod->depends[$i] . ".class.php")) {
                        activateModule($objMod->depends[$i]);
                    }
                }
            }
        }
        if (isset($objMod->conflictwith) && is_array($objMod->conflictwith) && !empty($objMod->conflictwith)) {
            // Desactivation des modules qui entrent en conflit
            $num = count($objMod->conflictwith);
            for ($i = 0; $i < $num; $i++) {
                foreach ($modulesdir as $dir) {
                    if (file_exists($dir . $objMod->conflictwith[$i] . ".class.php")) {
                        unActivateModule($objMod->conflictwith[$i], 0);
                    }
                }
            }
        }
    }
    return $ret;
}
Ejemplo n.º 5
0
 /**
  * Adds a product to the order
  *
  * @param Commande $object Order object
  * @param Product $prod Product to add
  * @param int $qty Quantity of the product
  * @throws Exception
  */
 public static function addOrderLine(Commande $object, Product $prod, $qty)
 {
     global $db, $conf, $mysoc, $langs;
     require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
     $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
     $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
     if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
         $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
         $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
         $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
         if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) {
             $tva_tx = $prod->multiprices_tva_tx[$object->thirdparty->price_level];
         }
         if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) {
             $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level];
         }
     } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
         require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
         $prodcustprice = new Productcustomerprice($db);
         $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
         $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
         if ($result >= 0) {
             if (count($prodcustprice->lines) > 0) {
                 $pu_ht = price($prodcustprice->lines[0]->price);
                 $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
                 $price_base_type = $prodcustprice->lines[0]->price_base_type;
                 $prod->tva_tx = $prodcustprice->lines[0]->tva_tx;
             } else {
                 $pu_ht = $prod->price;
                 $pu_ttc = $prod->price_ttc;
                 $price_base_type = $prod->price_base_type;
             }
         } else {
             throw new Exception($prodcustprice->error);
         }
     } else {
         $pu_ht = $prod->price;
         $pu_ttc = $prod->price_ttc;
         $price_base_type = $prod->price_base_type;
     }
     // if price ht is forced (ie: calculated by margin rate and cost price)
     if (!empty($price_ht)) {
         $pu_ht = price2num($price_ht, 'MU');
         $pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
     } elseif ($tva_tx != $prod->tva_tx) {
         if ($price_base_type != 'HT') {
             $pu_ht = price2num($pu_ttc / (1 + $tva_tx / 100), 'MU');
         } else {
             $pu_ttc = price2num($pu_ht * (1 + $tva_tx / 100), 'MU');
         }
     }
     // Define output language
     if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
         $outputlangs = $langs;
         $newlang = '';
         if (empty($newlang) && GETPOST('lang_id')) {
             $newlang = GETPOST('lang_id');
         }
         if (empty($newlang)) {
             $newlang = $object->thirdparty->default_lang;
         }
         if (!empty($newlang)) {
             $outputlangs = new Translate("", $conf);
             $outputlangs->setDefaultLang($newlang);
         }
         $desc = !empty($prod->multilangs[$outputlangs->defaultlang]["description"]) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
     } else {
         $desc = $prod->description;
     }
     // Add custom code and origin country into description
     if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
         $tmptxt = '(';
         if (!empty($prod->customcode)) {
             $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
         }
         if (!empty($prod->customcode) && !empty($prod->country_code)) {
             $tmptxt .= ' - ';
         }
         if (!empty($prod->country_code)) {
             $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
         }
         $tmptxt .= ')';
         $desc = dol_concatdesc($desc, $tmptxt);
     }
     //3.9.0 version added support for price units
     if (versioncompare(versiondolibarrarray(), array(3, 9, 0)) >= 0) {
         $fk_unit = $prod->fk_unit;
     } else {
         $fk_unit = null;
     }
     // Local Taxes
     $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
     $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
     $info_bits = 0;
     if ($tva_npr) {
         $info_bits |= 0x1;
     }
     //Percent remise
     if (!empty($object->thirdparty->remise_percent)) {
         $percent_remise = $object->thirdparty->remise_percent;
     } else {
         $percent_remise = 0;
     }
     // Insert line
     $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $prod->id, $percent_remise, $info_bits, 0, $price_base_type, $pu_ttc, '', '', $prod->type, -1, 0, 0, null, 0, '', 0, $fk_unit);
     if ($result < 0) {
         throw new Exception($langs->trans('ErrorAddOrderLine', $prod->ref));
     }
 }
Ejemplo n.º 6
0
            if ($row['rowid'] == $user->id) {
                echo '<strong>';
            }
            echo $row['firstname'] . ' ' . $row['lastname'] . ' :';
            echo '<PRE>' . dol_buildpath('cdav/server.php', 2) . '/calendars/' . $user->login . '/' . $row['rowid'] . '-cal-' . $row['login'] . '</PRE><br/>';
            if ($row['rowid'] == $user->id) {
                echo '</strong>';
            }
        }
    } else {
        echo '<PRE>' . dol_buildpath('cdav/server.php', 2) . '/calendars/' . $user->login . '/' . $user->id . '-cal-' . $user->login . '</PRE>';
    }
} elseif ($type == 'ICS') {
    echo '<h3>' . $langs->trans('URLforICS') . '</h3>';
    if (isset($user->rights->agenda->allactions->read) && $user->rights->agenda->allactions->read) {
        if (versioncompare(versiondolibarrarray(), array(3, 7, 9)) > 0) {
            $fk_soc_fieldname = 'fk_soc';
        } else {
            $fk_soc_fieldname = 'fk_societe';
        }
        $sql = 'SELECT u.rowid, u.login, u.firstname, u.lastname
			FROM ' . MAIN_DB_PREFIX . 'user u WHERE ' . $fk_soc_fieldname . ' IS NULL
			ORDER BY login';
        $result = $db->query($sql);
        while ($row = $db->fetch_array($result)) {
            echo '<h4>' . $row['firstname'] . ' ' . $row['lastname'] . ' :</h4>';
            echo "<PRE>" . $langs->trans('Full') . " :\n" . dol_buildpath('cdav/ics.php', 2) . '?token=' . base64url_encode(mcrypt_ecb(MCRYPT_BLOWFISH, CDAV_URI_KEY, $row['rowid'] . '+ø+full', MCRYPT_ENCRYPT)) . "\n\n";
            echo $langs->trans('NoLabel') . " :\n" . dol_buildpath('cdav/ics.php', 2) . '?token=' . base64url_encode(mcrypt_ecb(MCRYPT_BLOWFISH, CDAV_URI_KEY, $row['rowid'] . '+ø+nolabel', MCRYPT_ENCRYPT)) . '</PRE><br/>';
        }
    } else {
        echo "<PRE>" . $langs->trans('Full') . " :\n" . dol_buildpath('cdav/ics.php', 2) . '?token=' . base64url_encode(mcrypt_ecb(MCRYPT_BLOWFISH, CDAV_URI_KEY, $user->id . '+ø+full', MCRYPT_ENCRYPT)) . "\n\n";
Ejemplo n.º 7
0
}
print '<li>';
print '<a target="_blank" href="' . $url . '" rel="external">' . $title . '</a>';
print '</li>';
$url = 'http://partners.dolibarr.org';
$title = $langs->trans("ReferencedPreferredPartners");
print '<li>';
print '<a target="_blank" href="' . $url . '" rel="external">' . $title . '</a>';
print '</li>';
print '</ul>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
if ($youuselaststable) {
    print '<br>';
    print '<br>';
    $tmp = versiondolibarrarray();
    if (empty($tmp[2]) && strpos($tmp[1], '0') === 0 || strpos($tmp[2], '0') === 0) {
        print $langs->trans("TitleExampleForMajorRelease") . ':<br>';
        print '<textarea style="width:80%; min-height: 60px">';
        print $langs->trans("ExampleOfNewsMessageForMajorRelease", DOL_VERSION, DOL_VERSION);
        print '</textarea>';
    } else {
        print $langs->trans("TitleExampleForMaintenanceRelease") . ':<br>';
        print '<textarea style="width:80%; min-height: 60px">';
        print $langs->trans("ExampleOfNewsMessageForMaintenanceRelease", DOL_VERSION, DOL_VERSION);
        print '</textarea>';
    }
}
llxFooter();
$db->close();