static function update(&$PDOdb, $id_charge, $periode, $date_fin_rec, $nb_previsionnel, $montant)
 {
     global $db;
     if (!empty($date_fin_rec) && !preg_match('/([0-9]{2}[\\/-]?){2}([0-9]{4})/', $date_fin_rec)) {
         return false;
     }
     if ($nb_previsionnel < 0) {
         return false;
     }
     $recurrence = self::get_recurrence($PDOdb, $id_charge);
     $recurrence->fk_chargesociale = $id_charge;
     $recurrence->periode = $periode;
     $recurrence->nb_previsionnel = $nb_previsionnel;
     $recurrence->montant = $montant;
     if (!empty($date_fin_rec)) {
         $date = explode('/', $date_fin_rec);
         // $recurrence->date_fin je dirais que c'est déjà init
         $recurrence->date_fin = dol_mktime(0, 0, 0, $date[1], $date[0], $date[2]);
     } else {
         $recurrence->date_fin = null;
     }
     $recurrence->save($PDOdb);
     $message = 'Récurrence de la charge sociale ' . $id_charge . ' enregistrée. (' . TRecurrence::$TPeriodes[$periode] . ')';
     setEventMessage($message);
     $task = new TCronRecurrence($db);
     $task->run();
     return true;
 }
function _priceUpdateDolibarr(&$db, &$conf, &$langs)
{
    dol_include_once('/product/class/product.class.php');
    $error = 0;
    $fk_category = GETPOST('fk_category', 'int');
    $tms = dol_mktime(GETPOST('tmshour', 'int'), GETPOST('tmsmin', 'int'), 0, GETPOST('tmsmonth', 'int'), GETPOST('tmsday', 'int'), GETPOST('tmsyear', 'int'));
    $percentage = (double) GETPOST('percentage');
    if ($fk_category <= -1) {
        setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('quickpriceupdate_category_required')), null, 'errors');
        $error++;
    }
    if ($tms == '') {
        setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('quickpriceupdate_date_required')), null, 'errors');
        $error++;
    }
    if (!$error && $percentage != 0) {
        $tms = date('Y-m-d H:i:00', $tms);
        _priceUpdateDolibarrAction($db, $conf, $langs, $fk_category, $tms, $percentage);
    }
}
示例#3
0
 /**
  * return array_options array for object by extrafields value (using for data send by forms)
  *
  * @param  array   $extralabels    $array of extrafields
  * @param  string  $keyprefix      Prefix string to add into name and id of field (can be used to avoid duplicate names)
  * @param  string  $keysuffix      Suffix string to add into name and id of field (can be used to avoid duplicate names)
  * @return int                     1 if array_options set / 0 if no value
  */
 function getOptionalsFromPost($extralabels, $keyprefix = '', $keysuffix = '')
 {
     global $_POST;
     $array_options = array();
     if (is_array($extralabels)) {
         // Get extra fields
         foreach ($extralabels as $key => $value) {
             $key_type = $this->attribute_type[$key];
             if (in_array($key_type, array('date', 'datetime'))) {
                 // Clean parameters
                 $value_key = dol_mktime($_POST[$keysuffix . "options_" . $key . $keyprefix . "hour"], $_POST[$keysuffix . "options_" . $key . $keyprefix . "min"], 0, $_POST[$keysuffix . "options_" . $key . $keyprefix . "month"], $_POST[$keysuffix . "options_" . $key . $keyprefix . "day"], $_POST[$keysuffix . "options_" . $key . $keyprefix . "year"]);
             } else {
                 if (in_array($key_type, array('checkbox'))) {
                     $value_arr = GETPOST($keysuffix . "options_" . $key . $keyprefix);
                     // Make sure we get an array even if there's only one checkbox
                     $value_arr = (array) $value_arr;
                     $value_key = implode(',', $value_arr);
                 } else {
                     if (in_array($key_type, array('price', 'double'))) {
                         $value_arr = GETPOST($keysuffix . "options_" . $key . $keyprefix);
                         $value_key = price2num($value_arr);
                     } else {
                         $value_key = GETPOST($keysuffix . "options_" . $key . $keyprefix);
                     }
                 }
             }
             $array_options[$keysuffix . "options_" . $key] = $value_key;
             // No keyprefix here. keyprefix is used only for read.
         }
         return $array_options;
     } else {
         return 0;
     }
 }
示例#4
0
/**	Return first day of week for a date
 *
 *	@param		int		$day		Day
 * 	@param		int		$month		Month
 *  @param		int		$year		Year
 * 	@param		int		$gm			False = Return date to compare with server TZ, True to compare with GM date.
 *	@return		array				year,month, week,first_day,prev_year,prev_month,prev_day
 */
function dol_get_first_day_week($day, $month, $year, $gm = false)
{
    global $conf;
    $date = dol_mktime(0, 0, 0, $month, $day, $year, $gm);
    //Checking conf of start week
    $start_week = isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1;
    $tmparray = dol_getdate($date, true);
    //Calculate days to count
    $days = $start_week - $tmparray['wday'];
    if ($days >= 1) {
        $days = 7 - $days;
    }
    $days = abs($days);
    $seconds = $days * 24 * 60 * 60;
    //Get first day of week
    $tmpday = date($tmparray[0]) - $seconds;
    $tmpday = date("d", $tmpday);
    //Check first day of week is form this month or not
    if ($tmpday > $day) {
        $prev_month = $month - 1;
        $prev_year = $year;
        if ($prev_month == 0) {
            $prev_month = 12;
            $prev_year = $year - 1;
        }
    } else {
        $prev_month = $month;
        $prev_year = $year;
    }
    //Get first day of next week
    $tmptime = dol_mktime(12, 0, 0, $month, $tmpday, $year, 1, 0);
    $tmptime -= 24 * 60 * 60 * 7;
    $tmparray = dol_getdate($tmptime, true);
    $prev_day = $tmparray['mday'];
    //Check first day of week is form this month or not
    if ($prev_day > $tmpday) {
        $prev_month = $month - 1;
        $prev_year = $year;
        if ($prev_month == 0) {
            $prev_month = 12;
            $prev_year = $year - 1;
        }
    }
    $week = date("W", dol_mktime(0, 0, 0, $month, $tmpday, $year, $gm));
    return array('year' => $year, 'month' => $month, 'week' => $week, 'first_day' => $tmpday, 'prev_year' => $prev_year, 'prev_month' => $prev_month, 'prev_day' => $prev_day);
}
示例#5
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;
     }
 }
示例#6
0
 // Third party
 print '<td class="liste_titre">';
 print '<input type="text" class="flat" size="12" name="search_name" value="' . dol_escape_htmltag($search_name) . '">';
 print '</td>';
 print '<td class="liste_titre" align="center">';
 $arrayofoperators = array('<' => '<', '>' => '>');
 print $form->selectarray('filter_op1', $arrayofoperators, $filter_op1, 1);
 print ' ';
 $filter_date1 = dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
 print $form->select_date($filter_date1, 'op1', 0, 0, 1, '', 1, 0, 1);
 print '</td>';
 print '<td class="liste_titre" align="center">';
 $arrayofoperators = array('<' => '<', '>' => '>');
 print $form->selectarray('filter_op2', $arrayofoperators, $filter_op2, 1);
 print ' ';
 $filter_date2 = dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
 print $form->select_date($filter_date2, 'op2', 0, 0, 1, '', 1, 0, 1);
 print '</td>';
 print '<td align="right">';
 $arrayofstatus = array('0' => $langs->trans("ServiceStatusInitial"), '4' => $langs->trans("ServiceStatusRunning"), '4&filter=notexpired' => $langs->trans("ServiceStatusNotLate"), '4&filter=expired' => $langs->trans("ServiceStatusLate"), '5' => $langs->trans("ServiceStatusClosed"));
 print $form->selectarray('search_status', $arrayofstatus, strstr($search_status, ',') ? -1 : $search_status, 1);
 print '</td>';
 print '<td class="liste_titre" align="right"><input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
 print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
 print "</td></tr>\n";
 $contractstatic = new Contrat($db);
 $productstatic = new Product($db);
 $var = True;
 while ($i < min($num, $limit)) {
     $obj = $db->fetch_object($resql);
     $var = !$var;
示例#7
0
     }
     print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
     print '. ';
     print '<br>';
     if ($absolute_discount) {
         print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
     } else {
         print $langs->trans("CompanyHasNoAbsoluteDiscount");
     }
     print ' <a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditGlobalDiscounts") . ')</a>';
     print '.';
     print '</td></tr>';
 }
 // Date invoice
 print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">';
 $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
 print $form->select_date($datefacture ? $datefacture : $dateinvoice, '', '', '', '', "add", 1, 1, 1);
 print '</td></tr>';
 // Payment term
 print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td colspan="2">';
 $form->select_conditions_paiements(isset($_POST['cond_reglement_id']) ? $_POST['cond_reglement_id'] : $cond_reglement_id, 'cond_reglement_id');
 print '</td></tr>';
 // Payment mode
 print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
 $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT');
 print '</td></tr>';
 // Bank Account
 if (isset($_POST['fk_account'])) {
     $fk_account = $_POST['fk_account'];
 }
 print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
     $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature')) . "<br>\n";
 }
 if (empty($_POST["lastname"])) {
     $error += 1;
     $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname")) . "<br>\n";
 }
 if (empty($_POST["firstname"])) {
     $error += 1;
     $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname")) . "<br>\n";
 }
 if (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
     $error += 1;
     $langs->load("errors");
     $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email")) . "<br>\n";
 }
 $birthday = dol_mktime($_POST["birthhour"], $_POST["birthmin"], $_POST["birthsec"], $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
 if ($_POST["birthmonth"] && empty($birthday)) {
     $error += 1;
     $langs->load("errors");
     $errmsg .= $langs->trans("ErrorBadDateFormat") . "<br>\n";
 }
 if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
     if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) {
         $error += 1;
         $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget")) . "<br>\n";
     }
 }
 if (isset($public)) {
     $public = 1;
 } else {
     $public = 0;
* PAGE
*
* Put here all code to build page
****************************************************/
$helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:M&oacute;dulo_DoliPos';
llxHeader('', '', $helpurl);
$html = new Form($db);
$year_current = strftime("%Y", dol_now());
$pastmonth = strftime("%m", dol_now()) - 1;
$pastmonthyear = $year_current;
if ($pastmonth == 0) {
    $pastmonth = 12;
    $pastmonthyear--;
}
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
if (empty($date_start) || empty($date_end)) {
    $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false);
    $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false);
}
$nom = $langs->trans("TicketSellsJournal");
//$nomlink=;
$builddate = time();
$description = $langs->trans("TicketDescSellsJournal");
$period = $html->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $html->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink);
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
$idpays = $p[0];
$sql = "SELECT f.rowid, f.ticketnumber, f.type, f.date_closed, fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
$sql .= " fd.total_localtax1, fd.total_localtax2, p.accountancy_code_sell, s.code_compta,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
示例#10
0
$langs->load("other");
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
// Security check
if ($user->societe_id) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
$object = new Contact($db);
/*
 * Action
 */
if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) {
    $ret = $object->fetch($id);
    // Note: Correct date should be completed with location to have exact GM time of birth.
    $object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]);
    $object->birthday_alert = $_POST["birthday_alert"];
    $result = $object->update_perso($id, $user);
    if ($result > 0) {
        $object->old_name = '';
        $object->old_firstname = '';
    } else {
        $error = $object->error;
    }
}
/*
 *	View
 */
$now = dol_now();
llxHeader('', $langs->trans("ContactsAddresses"), 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Empresas');
$form = new Form($db);
        $sortfield = "u.lastname";
    }
}
$page = GETPOST("page", 'int');
if ($page == -1) {
    $page = 0;
}
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$startdate = $enddate = '';
if (!empty($_POST['startdatemonth'])) {
    $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
}
if (!empty($_POST['enddatemonth'])) {
    $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
}
/*
 * View
 */
$userstatic = new User($db);
$companystatic = new Societe($db);
$invoicestatic = new Facture($db);
$form = new Form($db);
llxHeader('', $langs->trans("Margins") . ' - ' . $langs->trans("Agents"));
$text = $langs->trans("Margins");
print_fiche_titre($text);
// Show tabs
$head = marges_prepare_head($user);
$titre = $langs->trans("Margins");
$picto = 'margin';
示例#12
0
 /**
  *  Initialise an instance with random values.
  *  Used to build previews or test instances.
  *	id must be 0 if object instance is a specimen.
  *
  *	@param	string		$option		''=Create a specimen invoice with lines, 'nolines'=No lines
  *  @return	void
  */
 function initAsSpecimen($option = '')
 {
     global $user, $langs, $conf;
     $now = dol_now();
     $arraynow = dol_getdate($now);
     $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
     // Initialize parameters
     $this->id = 0;
     $this->ref = 'SPECIMEN';
     $this->specimen = 1;
     $this->facid = 1;
     $this->datepaye = $nownotime;
 }
示例#13
0
文件: task.php 项目: ADDAdev/Dolibarr
     setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), 'errors');
 }
 if (!$error) {
     $object->fetch($id, $ref);
     $tmparray = explode('_', $_POST['task_parent']);
     $task_parent = $tmparray[1];
     if (empty($task_parent)) {
         $task_parent = 0;
     }
     // If task_parent is ''
     $object->label = $_POST["label"];
     $object->description = $_POST['description'];
     $object->fk_task_parent = $task_parent;
     $object->planned_workload = $planned_workload;
     $object->date_start = dol_mktime($_POST['dateohour'], $_POST['dateomin'], 0, $_POST['dateomonth'], $_POST['dateoday'], $_POST['dateoyear'], 'user');
     $object->date_end = dol_mktime($_POST['dateehour'], $_POST['dateemin'], 0, $_POST['dateemonth'], $_POST['dateeday'], $_POST['dateeyear'], 'user');
     $object->progress = $_POST['progress'];
     // Fill array 'array_options' with data from add form
     $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
     if ($ret < 0) {
         $error++;
     }
     if (!$error) {
         $result = $object->update($user);
         if ($result < 0) {
             setEventMessages($object->error, $object->errors, 'errors');
         }
     }
 } else {
     $action = 'edit';
 }
示例#14
0
if (!empty($conf->commande->enabled)) {
    $langs->load("orders");
}
if (!empty($conf->propal->enabled)) {
    $langs->load("propal");
}
if (!empty($conf->ficheinter->enabled)) {
    $langs->load("interventions");
}
$projectid = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$datesrfc = GETPOST('datesrfc');
$dateerfc = GETPOST('dateerfc');
$dates = dol_mktime(0, 0, 0, GETPOST('datesmonth'), GETPOST('datesday'), GETPOST('datesyear'));
$datee = dol_mktime(23, 59, 59, GETPOST('dateemonth'), GETPOST('dateeday'), GETPOST('dateeyear'));
if (empty($dates) && !empty($datesrfc)) {
    $dates = dol_stringtotime($datesrfc);
}
if (empty($datee) && !empty($dateerfc)) {
    $datee = dol_stringtotime($dateerfc);
}
if (!isset($_POST['datesrfc']) && !isset($_POST['datesday']) && !empty($conf->global->PROJECT_LINKED_ELEMENT_DEFAULT_FILTER_YEAR)) {
    $new = dol_now();
    $tmp = dol_getdate($new);
    //$datee=$now
    //$dates=dol_time_plus_duree($datee, -1, 'y');
    $dates = dol_get_first_day($tmp['year'], 1);
}
if ($projectid == '' && $ref == '') {
    dol_print_error('', 'Bad parameter');
示例#15
0
 // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
 $hookmanager->initHooks(array('externalbalance'));
 $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action);
 // Note that $action and $object may have been modified by some hooks
 if (!is_array($coll_listbuy) && $coll_listbuy == -1) {
     $langs->load("errors");
     print '<tr><td colspan="5">' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '</td></tr>';
     break;
 }
 if (!is_array($coll_listbuy) && $coll_listbuy == -2) {
     print '<tr><td colspan="5">' . $langs->trans("FeatureNotYetAvailable") . '</td></tr>';
     break;
 }
 $var = !$var;
 print "<tr " . $bc[$var] . ">";
 print '<td class="nowrap"><a href="quadri_detail.php?leftmenu=tax_vat&month=' . $m . '&year=' . $y . '">' . dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y") . '</a></td>';
 $x_coll = 0;
 foreach ($coll_listsell as $vatrate => $val) {
     $x_coll += $val['vat'];
 }
 $subtotalcoll = $subtotalcoll + $x_coll;
 print "<td class=\"nowrap\" align=\"right\">" . price($x_coll) . "</td>";
 $x_paye = 0;
 foreach ($coll_listbuy as $vatrate => $val) {
     $x_paye += $val['vat'];
 }
 $subtotalpaye = $subtotalpaye + $x_paye;
 print "<td class=\"nowrap\" align=\"right\">" . price($x_paye) . "</td>";
 $diff = $x_coll - $x_paye;
 $total = $total + $diff;
 $subtotal = $subtotal + $diff;
示例#16
0
// Search criteria
if ($search_ref) {
    $sql .= " AND bc.number=" . $search_ref;
}
if ($search_account > 0) {
    $sql .= " AND bc.fk_bank_account=" . $search_account;
}
if ($search_amount) {
    $sql .= " AND bc.amount='" . $db->escape(price2num(trim($search_amount))) . "'";
}
if ($month > 0) {
    if ($year > 0 && empty($day)) {
        $sql .= " AND bc.date_bordereau BETWEEN '" . $db->idate(dol_get_first_day($year, $month, false)) . "' AND '" . $db->idate(dol_get_last_day($year, $month, false)) . "'";
    } else {
        if ($year > 0 && !empty($day)) {
            $sql .= " AND bc.date_bordereau BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "' AND '" . $db->idate(dol_mktime(23, 59, 59, $month, $day, $year)) . "'";
        } else {
            $sql .= " AND date_format(bc.date_bordereau, '%m') = '" . $month . "'";
        }
    }
} else {
    if ($year > 0) {
        $sql .= " AND bc.date_bordereau BETWEEN '" . $db->idate(dol_get_first_day($year, 1, false)) . "' AND '" . $db->idate(dol_get_last_day($year, 12, false)) . "'";
    }
}
$sql .= " ORDER BY {$sortfield} {$sortorder}";
$sql .= $db->plimit($limit + 1, $offset);
//print "$sql";
$resql = $db->query($sql);
if ($resql) {
    $num = $db->num_rows($resql);
示例#17
0
    /**
     * testFactureCreate
     *
     * @return int
     */
    public function testFactureMercure()
    {
    	global $conf,$user,$langs,$db;
		$conf=$this->savconf;
		$user=$this->savuser;
		$langs=$this->savlangs;
		$db=$this->savdb;

		require_once dirname(__FILE__).'/../../htdocs/compta/facture/class/facture.class.php';
		require_once dirname(__FILE__).'/../../htdocs/core/modules/facture/mod_facture_mercure.php';

		//$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@3}';
		//$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@3}';
		$conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000@1}';
		$conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000@1}';

		$localobject=new Facture($this->savdb);
		$localobject->initAsSpecimen();
		$localobject->date=dol_mktime(0, 0, 0, 1, 1, 2012);
		$numbering=new mod_facture_mercure();
		$result=$numbering->getNextValue($mysoc, $localobject);
		print __METHOD__." result=".$result."\n";

		$localobject=new Facture($this->savdb);
		$localobject->initAsSpecimen();
		$localobject->date=dol_mktime(0, 0, 0, 1, 1, 2011);
		$numbering=new mod_facture_mercure();
		$result=$numbering->getNextValue($mysoc, $localobject);
    	print __METHOD__." result=".$result."\n";

    	$this->assertLessThan($result, 0);
    	return $result;
    }
示例#18
0
文件: card.php 项目: ADDAdev/Dolibarr
        setEventMessage($langs->trans($object->error), 'errors');
        $db->rollback();
    }
}
if ($action == 'setnum_paiement' && !empty($_POST['num_paiement'])) {
    $object->fetch($id);
    $res = $object->update_num($_POST['num_paiement']);
    if ($res === 0) {
        setEventMessage($langs->trans('PaymentNumberUpdateSucceeded'));
    } else {
        setEventMessage($langs->trans('PaymentNumberUpdateFailed'), 'errors');
    }
}
if ($action == 'setdatep' && !empty($_POST['datepday'])) {
    $object->fetch($id);
    $datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']);
    $res = $object->update_date($datepaye);
    if ($res === 0) {
        setEventMessage($langs->trans('PaymentDateUpdateSucceeded'));
    } else {
        setEventMessage($langs->trans('PaymentDateUpdateFailed'), 'errors');
    }
}
/*
 * View
 */
llxHeader();
$thirdpartystatic = new Societe($db);
$result = $object->fetch($id);
if ($result <= 0) {
    dol_print_error($db, 'Payement ' . $id . ' not found in database');
示例#19
0
文件: card.php 项目: Albertopf/prueba
    print '<input type="submit" class="button" value="' . $langs->trans("Add") . '">';
    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
    print '</div>';
    print "</form>";
}
// View or edit
if ($id > 0) {
    $result1 = $object->fetch($id);
    $result2 = $object->fetch_thirdparty();
    $result3 = $object->fetch_contact();
    $result4 = $object->fetch_userassigned();
    $result5 = $object->fetch_optionals($id, $extralabels);
    if ($listUserAssignedUpdated || $donotclearsession) {
        $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
        $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
        $object->fk_action = dol_getIdFromCode($db, GETPOST("actioncode"), 'c_actioncomm');
        $object->label = GETPOST("label");
        $object->datep = $datep;
        $object->datef = $datef;
        $object->percentage = $percentage;
        $object->priority = GETPOST("priority");
        $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
        $object->location = GETPOST('location');
        $object->socid = GETPOST("socid");
        $object->contactid = GETPOST("contactid", 'int');
        //$object->societe->id = $_POST["socid"];			// deprecated
        //$object->contact->id = $_POST["contactid"];		// deprecated
        $object->fk_project = GETPOST("projectid", 'int');
        $object->note = GETPOST("note");
    }
示例#20
0
llxHeader();

$html = new Form($db);

/*
 * Action create
 */
if ($_GET["action"] == 'create')
{
	print_fiche_titre($langs->trans("NewTrip"));

	dol_htmloutput_errors($mesg);

	$datec = dol_mktime(12, 0, 0,
	$_POST["remonth"],
	$_POST["reday"],
	$_POST["reyear"]);

	print "<form name='add' action=\"fiche.php\" method=\"post\">\n";
	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
	print '<input type="hidden" name="action" value="add">';

	print '<table class="border" width="100%">';

	print "<tr>";
	print '<td width="25%" class="fieldrequired">'.$langs->trans("Type").'</td><td>';
	print $html->select_type_fees($_POST["type"]?$_POST["type"]:$_GET["type"],'type',1);
	print '</td></tr>';

	print "<tr>";
	print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
示例#21
0
            print '});
			</script>' . "\n";
        }
        print '<form id="payment_form" name="add_paiement" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
        print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
        print '<input type="hidden" name="action" value="add_paiement">';
        print '<input type="hidden" name="facid" value="' . $facture->id . '">';
        print '<input type="hidden" name="socid" value="' . $facture->socid . '">';
        print '<input type="hidden" name="type" value="' . $facture->type . '">';
        print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="' . dol_escape_htmltag($facture->client->name) . '">';
        print '<table class="border" width="100%">';
        // Third party
        print '<tr><td><span class="fieldrequired">' . $langs->trans('Company') . '</span></td><td colspan="2">' . $facture->client->getNomUrl(4) . "</td></tr>\n";
        // Date payment
        print '<tr><td><span class="fieldrequired">' . $langs->trans('Date') . '</span></td><td>';
        $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
        $datepayment = $datepayment == '' ? empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : 0 : $datepayment;
        $html->select_date($datepayment, '', '', '', 0, "add_paiement", 1, 1);
        print '</td>';
        print '<td>' . $langs->trans('Comments') . '</td></tr>';
        $rowspan = 5;
        if ($conf->use_javascript_ajax && !empty($conf->global->MAIN_JS_ON_PAYMENT)) {
            $rowspan++;
        }
        // Payment mode
        print '<tr><td><span class="fieldrequired">' . $langs->trans('PaymentMode') . '</span></td><td>';
        $html->select_types_paiements(GETPOST('paiementcode') ? GETPOST('paiementcode') : $facture->mode_reglement_code, 'paiementcode', '', 2);
        print "</td>\n";
        print '<td rowspan="' . $rowspan . '" valign="top">';
        print '<textarea name="comment" wrap="soft" cols="60" rows="' . ROWS_4 . '">' . (empty($_POST['comment']) ? '' : $_POST['comment']) . '</textarea></td>';
        print '</tr>';
    $page = 0;
}
$limit = $conf->liste_limit;
$offset = $limit * $page;
$dir = $conf->banque->dir_output . '/bordereau/';
$filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
$filteraccountid = GETPOST('accountid');
$object = new RemiseCheque($db);
/*
 * Actions
 */
if ($action == 'setdate' && $user->rights->banque->cheque) {
    $result = $object->fetch(GETPOST('id', 'int'));
    if ($result > 0) {
        //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
        $date = dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']);
        $result = $object->set_date($user, $date);
        if ($result < 0) {
            setEventMessage($object->error, 'errors');
        }
    } else {
        setEventMessage($object->error, 'errors');
    }
}
/*
 * Actions
 */
if ($action == 'setrefext' && $user->rights->banque->cheque) {
    $result = $object->fetch(GETPOST('id', 'int'));
    if ($result > 0) {
        $ref_ext = GETPOST('ref_ext');
示例#23
0
    $req_enddtday = "";
    $req_enddtyear = "";
    $req_enddt = "";
}
/*
 * Action
 */
$dateop = -1;
if ($action == 'add' && $id && !isset($_POST["cancel"]) && $user->rights->banque->modifier) {
    $error = 0;
    if (price2num($_POST["credit"]) > 0) {
        $amount = price2num($_POST["credit"]);
    } else {
        $amount = -price2num($_POST["debit"]);
    }
    $dateop = dol_mktime(12, 0, 0, $_POST["opmonth"], $_POST["opday"], $_POST["opyear"]);
    $operation = $_POST["operation"];
    $num_chq = $_POST["num_chq"];
    $label = $_POST["label"];
    $cat1 = $_POST["cat1"];
    if (!$dateop) {
        $error++;
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
    }
    if (!$operation) {
        $error++;
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors');
    }
    if (!$amount) {
        $error++;
        setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors');
示例#24
0
/**
 * Show event of a particular day for a user
 *
 * @param	string	$username		Login
 * @param   int		$day            Day
 * @param   int		$month          Month
 * @param   int		$year           Year
 * @param   int		$monthshown     Current month shown in calendar view
 * @param   string	$style          Style to use for this day
 * @param   array	$eventarray    	Array of events
 * @param   int		$maxprint       Nb of actions to show each day on month view (0 means no limit)
 * @param   int		$maxnbofchar    Nb of characters to show for event line
 * @param   string	$newparam       Parameters on current URL
 * @param   int		$showinfo       Add extended information (used by day view)
 * @param   int		$minheight      Minimum height for each event. 60px by default.
 * @param	boolean	$showheader		Show header
 * @param	array	$colorsbytype	Array with colors by type
 * @param	bool	$var			true or false for alternat style on tr/td
 * @return	void
 */
function show_day_events2($username, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $showheader = false, $colorsbytype = array(), $var = false)
{
    global $db;
    global $user, $conf, $langs, $hookmanager, $action;
    global $filter, $filtert, $status, $actioncode;
    // Filters used into search form
    global $theme_datacolor;
    // Array with a list of different we can use (come from theme)
    global $cachethirdparties, $cachecontacts, $colorindexused;
    global $begin_h, $end_h;
    $cases1 = array();
    // Color first half hour
    $cases2 = array();
    // Color second half hour
    $curtime = dol_mktime(0, 0, 0, $month, $day, $year);
    $i = 0;
    $nummytasks = 0;
    $numother = 0;
    $numbirthday = 0;
    $numical = 0;
    $numicals = array();
    $ymd = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day);
    $nextindextouse = count($colorindexused);
    // At first run, this is 0, so fist user has 0, next 1, ...
    //if ($username->id && $day==1) var_dump($eventarray);
    // We are in a particular day for $username, now we scan all events
    foreach ($eventarray as $daykey => $notused) {
        $annee = date('Y', $daykey);
        $mois = date('m', $daykey);
        $jour = date('d', $daykey);
        //print $annee.'-'.$mois.'-'.$jour.' '.$year.'-'.$month.'-'.$day."<br>\n";
        if ($day == $jour && $month == $mois && $year == $annee) {
            // Scan all event for this date
            foreach ($eventarray[$daykey] as $index => $event) {
                $keysofuserassigned = array_keys($event->userassigned);
                if (!in_array($username->id, $keysofuserassigned)) {
                    continue;
                }
                // We discard record if event is from another user than user we want to show
                //if ($username->id != $event->userownerid) continue;	// We discard record if event is from another user than user we want to show
                $parameters = array();
                $reshook = $hookmanager->executeHooks('formatEvent', $parameters, $event, $action);
                // Note that $action and $object may have been modified by some hooks
                if ($reshook < 0) {
                    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
                }
                $ponct = $event->date_start_in_calendar == $event->date_end_in_calendar;
                // Define $color (Hex string like '0088FF') and $cssclass of event
                $color = -1;
                $cssclass = '';
                $colorindex = -1;
                if (in_array($user->id, $keysofuserassigned)) {
                    $nummytasks++;
                    $cssclass = 'family_mytasks';
                    if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
                        $color = $event->type_color;
                    }
                } else {
                    if ($event->type_code == 'ICALEVENT') {
                        $numical++;
                        if (!empty($event->icalname)) {
                            if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
                                $numicals[dol_string_nospecial($event->icalname)] = 0;
                            }
                            $numicals[dol_string_nospecial($event->icalname)]++;
                        }
                        $color = $event->icalcolor;
                        $cssclass = !empty($event->icalname) ? 'family_ext' . md5($event->icalname) : 'family_other unsortable';
                    } else {
                        if ($event->type_code == 'BIRTHDAY') {
                            $numbirthday++;
                            $colorindex = 2;
                            $cssclass = 'family_birthday unsortable';
                            $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
                        } else {
                            $numother++;
                            $cssclass = 'family_other';
                            if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
                                $color = $event->type_color;
                            }
                        }
                    }
                }
                if ($color < 0) {
                    // Define color index if not yet defined
                    $idusertouse = $event->userownerid ? $event->userownerid : 0;
                    if (isset($colorindexused[$idusertouse])) {
                        $colorindex = $colorindexused[$idusertouse];
                        // Color already assigned to this user
                    } else {
                        $colorindex = $nextindextouse;
                        $colorindexused[$idusertouse] = $colorindex;
                        if (!empty($theme_datacolor[$nextindextouse + 1])) {
                            $nextindextouse++;
                        }
                        // Prepare to use next color
                    }
                    // Define color
                    $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
                }
                //$cssclass=$cssclass.' '.$cssclass.'_day_'.$ymd;
                // Define all rects with event (cases1 is first half hour, cases2 is second half hour)
                for ($h = $begin_h; $h < $end_h; $h++) {
                    //if ($username->id == 1 && $day==1) print 'h='.$h;
                    $newcolor = '';
                    //init
                    if (empty($event->fulldayevent)) {
                        $a = dol_mktime((int) $h, 0, 0, $month, $day, $year, false, false);
                        $b = dol_mktime((int) $h, 30, 0, $month, $day, $year, false, false);
                        $c = dol_mktime((int) $h + 1, 0, 0, $month, $day, $year, false, false);
                        $dateendtouse = $event->date_end_in_calendar;
                        if ($dateendtouse == $event->date_start_in_calendar) {
                            $dateendtouse++;
                        }
                        //print dol_print_date($event->date_start_in_calendar,'dayhour').'-'.dol_print_date($a,'dayhour').'-'.dol_print_date($b,'dayhour').'<br>';
                        if ($event->date_start_in_calendar < $b && $dateendtouse > $a) {
                            $busy = $event->transparency;
                            $cases1[$h][$event->id]['busy'] = $busy;
                            $cases1[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour');
                            if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
                                $tmpa = dol_getdate($event->date_start_in_calendar, true);
                                $tmpb = dol_getdate($event->date_end_in_calendar, true);
                                if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
                                    $cases1[$h][$event->id]['string'] .= '-' . dol_print_date($event->date_end_in_calendar, 'hour');
                                } else {
                                    $cases1[$h][$event->id]['string'] .= '-' . dol_print_date($event->date_end_in_calendar, 'dayhour');
                                }
                            }
                            $cases1[$h][$event->id]['string'] .= ' - ' . $event->label;
                            $cases1[$h][$event->id]['typecode'] = $event->type_code;
                            if ($event->socid) {
                                //$cases1[$h][$event->id]['string'].='xxx';
                            }
                            $cases1[$h][$event->id]['color'] = $color;
                        }
                        if ($event->date_start_in_calendar < $c && $dateendtouse > $b) {
                            $busy = $event->transparency;
                            $cases2[$h][$event->id]['busy'] = $busy;
                            $cases2[$h][$event->id]['string'] = dol_print_date($event->date_start_in_calendar, 'dayhour');
                            if ($event->date_end_in_calendar && $event->date_end_in_calendar != $event->date_start_in_calendar) {
                                $tmpa = dol_getdate($event->date_start_in_calendar, true);
                                $tmpb = dol_getdate($event->date_end_in_calendar, true);
                                if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) {
                                    $cases2[$h][$event->id]['string'] .= '-' . dol_print_date($event->date_end_in_calendar, 'hour');
                                } else {
                                    $cases2[$h][$event->id]['string'] .= '-' . dol_print_date($event->date_end_in_calendar, 'dayhour');
                                }
                            }
                            $cases2[$h][$event->id]['string'] .= ' - ' . $event->label;
                            $cases2[$h][$event->id]['typecode'] = $event->type_code;
                            if ($event->socid) {
                                //$cases2[$h][$event->id]['string'].='xxx';
                            }
                            $cases2[$h][$event->id]['color'] = $color;
                        }
                    } else {
                        $busy = $event->transparency;
                        $cases1[$h][$event->id]['busy'] = $busy;
                        $cases2[$h][$event->id]['busy'] = $busy;
                        $cases1[$h][$event->id]['string'] = $event->label;
                        $cases2[$h][$event->id]['string'] = $event->label;
                        $cases1[$h][$event->id]['typecode'] = $event->type_code;
                        $cases2[$h][$event->id]['typecode'] = $event->type_code;
                        $cases1[$h][$event->id]['color'] = $color;
                        $cases2[$h][$event->id]['color'] = $color;
                    }
                }
                $i++;
            }
            break;
            // We found the date we were looking for. No need to search anymore.
        }
    }
    for ($h = $begin_h; $h < $end_h; $h++) {
        $color1 = '';
        $color2 = '';
        $style1 = '';
        $style2 = '';
        $string1 = '&nbsp;';
        $string2 = '&nbsp;';
        $title1 = '';
        $title2 = '';
        if (isset($cases1[$h]) && $cases1[$h] != '') {
            //$title1.=count($cases1[$h]).' '.(count($cases1[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
            if (count($cases1[$h]) > 1) {
                $title1 .= count($cases1[$h]) . ' ' . (count($cases1[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
            }
            $string1 = '&nbsp;';
            if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
                $style1 = 'peruser_notbusy';
            } else {
                $style1 = 'peruser_busy';
            }
            foreach ($cases1[$h] as $id => $ev) {
                if ($ev['busy']) {
                    $style1 = 'peruser_busy';
                }
            }
        }
        if (isset($cases2[$h]) && $cases2[$h] != '') {
            //$title2.=count($cases2[$h]).' '.(count($cases2[$h])==1?$langs->trans("Event"):$langs->trans("Events"));
            if (count($cases2[$h]) > 1) {
                $title2 .= count($cases2[$h]) . ' ' . (count($cases2[$h]) == 1 ? $langs->trans("Event") : $langs->trans("Events"));
            }
            $string2 = '&nbsp;';
            if (empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
                $style2 = 'peruser_notbusy';
            } else {
                $style2 = 'peruser_busy';
            }
            foreach ($cases2[$h] as $id => $ev) {
                if ($ev['busy']) {
                    $style2 = 'peruser_busy';
                }
            }
        }
        if ($h == $begin_h) {
            echo '<td class="' . $style . '_peruserleft cal_peruser"' . ($var ? ' style="background: #F8F8F8"' : '') . '>';
        } else {
            echo '<td class="' . $style . ' cal_peruser"' . ($var ? ' style="background: #F8F8F8"' : '') . '>';
        }
        if (count($cases1[$h]) == 1) {
            $ids = array_keys($cases1[$h]);
            $output = array_slice($cases1[$h], 0, 1);
            if ($output[0]['string']) {
                $title1 .= ($title1 ? ' - ' : '') . $output[0]['string'];
            }
            if ($output[0]['color']) {
                $color1 = $output[0]['color'];
            }
        } else {
            if (count($cases1[$h]) > 1) {
                $color1 = '222222';
            }
        }
        if (count($cases2[$h]) == 1) {
            $ids = array_keys($cases2[$h]);
            $output = array_slice($cases2[$h], 0, 1);
            if ($output[0]['string']) {
                $title2 .= ($title2 ? ' - ' : '') . $output[0]['string'];
            }
            if ($output[0]['color']) {
                $color2 = $output[0]['color'];
            }
        } else {
            if (count($cases2[$h]) > 1) {
                $color2 = '222222';
            }
        }
        $ids1 = '';
        $ids2 = '';
        if (count($cases1[$h]) && array_keys($cases1[$h])) {
            $ids1 = join(',', array_keys($cases1[$h]));
        }
        if (count($cases2[$h]) && array_keys($cases2[$h])) {
            $ids2 = join(',', array_keys($cases2[$h]));
        }
        //var_dump($cases1[$h]);
        print '<table class="nobordernopadding" width="100%">';
        print '<tr><td ' . ($color1 ? 'style="background: #' . $color1 . ';"' : '') . 'class="' . ($style1 ? $style1 . ' ' : '') . 'onclickopenref' . ($title1 ? ' cursorpointer' : '') . '" ref="ref_' . $username->id . '_' . sprintf("%04d", $year) . '_' . sprintf("%02d", $month) . '_' . sprintf("%02d", $day) . '_' . sprintf("%02d", $h) . '_00_' . ($ids1 ? $ids1 : 'none') . '"' . ($title1 ? ' title="' . $title1 . '"' : '') . '>';
        print $string1;
        print '</td><td ' . ($color2 ? 'style="background: #' . $color2 . ';"' : '') . 'class="' . ($style2 ? $style2 . ' ' : '') . 'onclickopenref' . ($title1 ? ' cursorpointer' : '') . '" ref="ref_' . $username->id . '_' . sprintf("%04d", $year) . '_' . sprintf("%02d", $month) . '_' . sprintf("%02d", $day) . '_' . sprintf("%02d", $h) . '_30_' . ($ids2 ? $ids2 : 'none') . '"' . ($title2 ? ' title="' . $title2 . '"' : '') . '>';
        print $string2;
        print '</td></tr>';
        print '</table>';
        print '</td>';
    }
}
}
// For "custom" directory
//require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php";
$langs->load("banks");
if (!$user->rights->pos->transfer) {
    accessforbidden();
}
$action = GETPOST('action', 'alpha');
/*
 * Action ajout d'un transfers
 */
if ($action == 'add') {
    $langs->load("errors");
    $dateo = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
    $label = GETPOST('label', 'alpha');
    $amount = GETPOST('amount', 'int');
    if (!$label) {
        $error = 1;
        setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), "errors");
    }
    if (!$amount) {
        $error = 1;
        setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), "errors");
    }
    if (!GETPOST('account_from', 'int')) {
        $error = 1;
        setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentities("TransferFrom")), "errors");
    }
    if (!GETPOST('account_to', 'int')) {
示例#26
0
    // If we create project, ref may be defined into POST but record does not yet exists into database
    if ($ret > 0) {
        $object->fetch_thirdparty();
        $id = $object->id;
    }
}
// Security check
$socid = GETPOST('socid');
if ($user->societe_id > 0) {
    $socid = $user->societe_id;
}
$result = restrictedArea($user, 'projet', $object->id);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$date_start = dol_mktime(0, 0, 0, GETPOST('projectstartmonth', 'int'), GETPOST('projectstartday', 'int'), GETPOST('projectstartyear', 'int'));
$date_end = dol_mktime(0, 0, 0, GETPOST('projectendmonth', 'int'), GETPOST('projectendday', 'int'), GETPOST('projectendyear', 'int'));
/*
 * Actions
 */
$parameters = array('id' => $socid, 'objcanvas' => $objcanvas);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
// Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
    // Cancel
    if ($cancel) {
        if (GETPOST("comefromclone") == 1) {
            $result = $object->delete($user);
            if ($result > 0) {
示例#27
0
}
if ($search_product_category > 0) {
    $sql .= " AND cp.fk_categorie = " . $search_product_category;
}
if ($socid > 0) {
    $sql .= ' AND s.rowid = ' . $socid;
}
if ($viewstatut != '') {
    $sql .= ' AND p.fk_statut IN (' . $viewstatut . ')';
}
if ($month > 0) {
    if ($year > 0 && empty($day)) {
        $sql .= " AND p.datep BETWEEN '" . $db->idate(dol_get_first_day($year, $month, false)) . "' AND '" . $db->idate(dol_get_last_day($year, $month, false)) . "'";
    } else {
        if ($year > 0 && !empty($day)) {
            $sql .= " AND p.datep BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "' AND '" . $db->idate(dol_mktime(23, 59, 59, $month, $day, $year)) . "'";
        } else {
            $sql .= " AND date_format(p.datep, '%m') = '" . $month . "'";
        }
    }
} else {
    if ($year > 0) {
        $sql .= " AND p.datep BETWEEN '" . $db->idate(dol_get_first_day($year, 1, false)) . "' AND '" . $db->idate(dol_get_last_day($year, 12, false)) . "'";
    }
}
if ($search_sale > 0) {
    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND c.fk_c_type_contact = tc.rowid AND tc.element='propal' AND tc.source='internal' AND c.element_id = p.rowid AND c.fk_socpeople = " . $search_user;
}
示例#28
0
    if ($result <= 0) {
        dol_print_error($db);
        exit;
    }
}
// Formulaire saisie salaire
if ($action == 'create') {
    $year_current = strftime("%Y", dol_now());
    $pastmonth = strftime("%m", dol_now()) - 1;
    $pastmonthyear = $year_current;
    if ($pastmonth == 0) {
        $pastmonth = 12;
        $pastmonthyear--;
    }
    $datesp = dol_mktime(0, 0, 0, $datespmonth, $datespday, $datespyear);
    $dateep = dol_mktime(23, 59, 59, $dateepmonth, $dateepday, $dateepyear);
    if (empty($datesp) || empty($dateep)) {
        $datesp = dol_get_first_day($pastmonthyear, $pastmonth, false);
        $dateep = dol_get_last_day($pastmonthyear, $pastmonth, false);
    }
    print '<form name="salary" action="' . $_SERVER["PHP_SELF"] . '" method="post">';
    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    print '<input type="hidden" name="action" value="add">';
    print_fiche_titre($langs->trans("NewSalaryPayment"), '', 'title_accountancy.png');
    dol_fiche_head('', '');
    print '<table class="border" width="100%">';
    print "<tr>";
    print '<td class="fieldrequired">' . $langs->trans("DatePayment") . '</td><td>';
    print $form->select_date(empty($datep) ? -1 : $datep, "datep", '', '', '', 'add', 1, 1);
    print '</td></tr>';
    print '<tr><td>' . $langs->trans("DateValue") . '</td><td>';
示例#29
0
$langs->load("bills");
$langs->load("compta");
$langs->load("companies");
$langs->load("products");
$langs->load("other");
// Date range
$year = GETPOST("year");
if (empty($year)) {
    $year_current = strftime("%Y", dol_now());
    $year_start = $year_current;
} else {
    $year_current = $year;
    $year_start = $year;
}
$date_start = dol_mktime(0, 0, 0, $_REQUEST["date_startmonth"], $_REQUEST["date_startday"], $_REQUEST["date_startyear"]);
$date_end = dol_mktime(23, 59, 59, $_REQUEST["date_endmonth"], $_REQUEST["date_endday"], $_REQUEST["date_endyear"]);
// Quarter
if (empty($date_start) || empty($date_end)) {
    $q = GETPOST("q");
    if (empty($q)) {
        if (isset($_REQUEST["month"])) {
            $date_start = dol_get_first_day($year_start, $_REQUEST["month"], false);
            $date_end = dol_get_last_day($year_start, $_REQUEST["month"], false);
        } else {
            $month_current = strftime("%m", dol_now());
            if ($month_current >= 10) {
                $q = 4;
            } elseif ($month_current >= 7) {
                $q = 3;
            } elseif ($month_current >= 4) {
                $q = 2;
require_once DOL_DOCUMENT_ROOT . '/compta/dons/class/don.class.php';
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
if (!empty($conf->projet->enabled)) {
    require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
$langs->load("companies");
$langs->load("donations");
$langs->load("bills");
$id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel');
$amount = GETPOST('amount');
$mesg = "";
$mesgs = array();
$don = new Don($db);
$donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
// Security check
$result = restrictedArea($user, 'don', $id);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('doncard'));
/*
 * Actions
 */
if ($action == 'update') {
    if (!empty($cancel)) {
        header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
        exit;
    }
    $error = 0;
    if (empty($donation_date)) {
        $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->trans("Date"));