本文整理汇总了PHP中DoliDB::idate方法的典型用法代码示例。如果您正苦于以下问题:PHP DoliDB::idate方法的具体用法?PHP DoliDB::idate怎么用?PHP DoliDB::idate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoliDB
的用法示例。
在下文中一共展示了DoliDB::idate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vat_by_date
/**
* Gets VAT to collect for the given year (and given quarter or month)
* The function gets the VAT in split results, as the VAT declaration asks
* to report the amounts for different VAT rates as different lines.
* This function also accounts recurrent invoices.
*
* @param DoliDB $db Database handler object
* @param int $y Year
* @param int $q Quarter
* @param string $date_start Start date
* @param string $date_end End date
* @param int $modetax 0 or 1 (option vat on debit)
* @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices)
* @param int $m Month
* @return array List of quarters with vat
*/
function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $m = 0)
{
global $conf;
$list = array();
if ($direction == 'sell') {
$invoicetable = 'facture';
$invoicedettable = 'facturedet';
$fk_facture = 'fk_facture';
$fk_facture2 = 'fk_facture';
$fk_payment = 'fk_paiement';
$total_tva = 'total_tva';
$total_localtax1 = 'total_localtax1';
$total_localtax2 = 'total_localtax2';
$paymenttable = 'paiement';
$paymentfacturetable = 'paiement_facture';
$invoicefieldref = 'facnumber';
}
if ($direction == 'buy') {
$invoicetable = 'facture_fourn';
$invoicedettable = 'facture_fourn_det';
$fk_facture = 'fk_facture_fourn';
$fk_facture2 = 'fk_facturefourn';
$fk_payment = 'fk_paiementfourn';
$total_tva = 'tva';
$total_localtax1 = 'total_localtax1';
$total_localtax2 = 'total_localtax2';
$paymenttable = 'paiementfourn';
$paymentfacturetable = 'paiementfourn_facturefourn';
$invoicefieldref = 'ref';
}
// CAS DES BIENS
// Define sql request
$sql = '';
if ($modetax == 1) {
// Count on delivery date (use invoice date as delivery is unknown)
$sql = "SELECT d.rowid, d.product_type as dtype, d." . $fk_facture . " as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d." . $total_tva . " as total_vat, d.description as descr,";
$sql .= " d." . $total_localtax1 . " as total_localtax1, d." . $total_localtax2 . " as total_localtax2, ";
$sql .= " d.date_start as date_start, d.date_end as date_end,";
$sql .= " f." . $invoicefieldref . " as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,";
$sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
$sql .= " 0 as payment_id, 0 as payment_amount";
$sql .= " FROM " . MAIN_DB_PREFIX . $invoicetable . " as f,";
$sql .= " " . MAIN_DB_PREFIX . "societe as s,";
$sql .= " " . MAIN_DB_PREFIX . $invoicedettable . " as d";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p on d.fk_product = p.rowid";
$sql .= " WHERE f.entity = " . $conf->entity;
$sql .= " AND f.fk_statut in (1,2)";
// Validated or paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2,5)";
} else {
$sql .= " AND f.type IN (0,1,2,3,5)";
}
$sql .= " AND f.rowid = d." . $fk_facture;
$sql .= " AND s.rowid = f.fk_soc";
if ($y && $m) {
$sql .= " AND f.datef >= '" . $db->idate(dol_get_first_day($y, $m, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, $m, false)) . "'";
} else {
if ($y) {
$sql .= " AND f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
}
}
if ($q) {
$sql .= " AND (date_format(f.datef,'%m') > " . ($q - 1) * 3 . " AND date_format(f.datef,'%m') <= " . $q * 3 . ")";
}
if ($date_start && $date_end) {
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
}
$sql .= " AND (d.product_type = 0";
// Limit to products
$sql .= " AND d.date_start is null AND d.date_end IS NULL)";
// enhance detection of service
$sql .= " ORDER BY d.rowid, d." . $fk_facture;
} else {
// Count on delivery date (use invoice date as delivery is unknown)
$sql = "SELECT d.rowid, d.product_type as dtype, d." . $fk_facture . " as facid, d.tva_tx as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d." . $total_tva . " as total_vat, d.description as descr,";
$sql .= " d." . $total_localtax1 . " as total_localtax1, d." . $total_localtax2 . " as total_localtax2, ";
$sql .= " d.date_start as date_start, d.date_end as date_end,";
$sql .= " f." . $invoicefieldref . " as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef as date_f, s.nom as company_name, s.rowid as company_id,";
$sql .= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
$sql .= " 0 as payment_id, 0 as payment_amount";
$sql .= " FROM " . MAIN_DB_PREFIX . $invoicetable . " as f,";
//.........这里部分代码省略.........
示例2: print_projecttasks_array
/**
* Return HTML table with list of projects and number of opened tasks
*
* @param DoliDB $db Database handler
* @param Form $form Object form
* @param int $socid Id thirdparty
* @param int $projectsListId Id of project I have permission on
* @param int $mytasks Limited to task I am contact to
* @param int $statut -1=No filter on statut, 0 or 1 = Filter on status
* @param array $listofoppstatus List of opportunity status
* @param array $hiddenfields List of info to not show ('projectlabel', 'declaredprogress', '...', )
* @return void
*/
function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array(), $hiddenfields = array())
{
global $langs, $conf, $user, $bc;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$projectstatic = new Project($db);
$thirdpartystatic = new Societe($db);
$sortfield = '';
$sortorder = '';
$project_year_filter = 0;
$title = $langs->trans("Projects");
if (strcmp($statut, '') && $statut >= 0) {
$title = $langs->trans("Projects") . ' ' . $langs->trans($projectstatic->statuts_long[$statut]);
}
$arrayidtypeofcontact = array();
print '<table class="noborder" width="100%">';
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as p";
if ($mytasks) {
$sql .= ", " . MAIN_DB_PREFIX . "projet_task as t";
$sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec";
$sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc";
} else {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet";
}
$sql .= " WHERE p.entity = " . $conf->entity;
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
if ($socid) {
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")";
}
if ($mytasks) {
$sql .= " AND p.rowid = t.fk_projet";
$sql .= " AND ec.element_id = t.rowid";
$sql .= " AND ec.fk_socpeople = " . $user->id;
$sql .= " AND ec.fk_c_type_contact = ctc.rowid";
// Replace the 2 lines with ec.fk_c_type_contact in $arrayidtypeofcontact
$sql .= " AND ctc.element = 'project_task'";
}
if ($statut >= 0) {
$sql .= " AND p.fk_statut = " . $statut;
}
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
if ($project_year_filter != "*") {
if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
$project_year_filter = date("Y");
}
$sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")";
$sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")";
}
}
// Get id of project we must show tasks
$arrayidofprojects = array();
$sql1 = "SELECT p.rowid as projectid";
$sql1 .= $sql;
$resql = $db->query($sql1);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ($i < $num) {
$objp = $db->fetch_object($resql);
$arrayidofprojects[$objp->projectid] = $objp->projectid;
$i++;
}
} else {
dol_print_error($db);
}
if (empty($arrayidofprojects)) {
$arrayidofprojects[0] = -1;
}
// Get list of project with calculation on tasks
$sql2 = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_soc, s.nom as socname, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount,";
$sql2 .= " COUNT(t.rowid) as nb, SUM(t.planned_workload) as planned_workload, SUM(t.planned_workload * t.progress / 100) as declared_progess_workload";
$sql2 .= " FROM " . MAIN_DB_PREFIX . "projet as p";
$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = p.fk_soc";
$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet";
$sql2 .= " WHERE p.rowid IN (" . join(',', $arrayidofprojects) . ")";
$sql2 .= " GROUP BY p.rowid, p.ref, p.title, p.fk_soc, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount";
$sql2 .= " ORDER BY p.title, p.ref";
$var = true;
$resql = $db->query($sql2);
if ($resql) {
$total_task = 0;
$total_opp_amount = 0;
$ponderated_opp_amount = 0;
$num = $db->num_rows($resql);
$i = 0;
print '<tr class="liste_titre">';
//.........这里部分代码省略.........
示例3: AddNotification
/**
* Add a notification
*
* @param DoliDB $db database handler
* @param User $user notification user
* @param string $action notification action
* @return int 0 if OK, <0 if KO
*/
function AddNotification($db, $user, $action)
{
$result = 0;
if ($this->DeleteNotification($user, $action) == 0) {
$now = dol_now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "notify_def (datec,fk_user, fk_soc, fk_contact, fk_action)";
$sql .= " VALUES (" . $db->idate($now) . "," . $user . ", 'NULL', 'NULL', '" . $action . "')";
dol_syslog("adnotiff: " . $sql);
if ($this->db->query($sql)) {
$result = 0;
} else {
$result = -1;
dol_syslog(get_class($this) . "::AddNotification Error {$result}");
}
}
return $result;
}
示例4: rebuild_merge_pdf
/**
* Function to build a compiled PDF
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @param string $diroutputpdf Dir to output file
* @param string $newlangid Lang id
* @param array $filter Array with filters
* @param date $dateafterdate Invoice after date
* @param date $datebeforedate Invoice before date
* @param date $paymentdateafter Payment after date (must includes hour)
* @param date $paymentdatebefore Payment before date (must includes hour)
* @param int $usestdout Add information onto standard output
* @param int $regenerate ''=Use existing PDF files, 'nameofpdf'=Regenerate all PDF files using the template
* @param string $filesuffix Suffix to add into file name of generated PDF
* @param string $paymentbankid Only if payment on this bank account id
* @param array $thirdpartiesid List of thirdparties id when using filter excludethirdpartiesid or onlythirdpartiesid
* @param string $fileprefix Prefix to add into filename of generated PDF
* @return int Error code
*/
function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filter, $dateafterdate, $datebeforedate, $paymentdateafter, $paymentdatebefore, $usestdout, $regenerate = 0, $filesuffix = '', $paymentbankid = '', $thirdpartiesid = '', $fileprefix = 'mergedpdf')
{
$sql = "SELECT DISTINCT f.rowid, f.facnumber";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
$sqlwhere = '';
$sqlorder = '';
if (in_array('all', $filter)) {
$sqlorder = " ORDER BY f.facnumber ASC";
}
if (in_array('date', $filter)) {
if (empty($sqlwhere)) {
$sqlwhere = ' WHERE ';
} else {
$sqlwhere .= " AND";
}
$sqlwhere .= " f.fk_statut > 0";
$sqlwhere .= " AND f.datef >= '" . $db->idate($dateafterdate) . "'";
$sqlwhere .= " AND f.datef <= '" . $db->idate($datebeforedate) . "'";
$sqlorder = " ORDER BY f.datef ASC";
}
if (in_array('nopayment', $filter)) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "paiement_facture as pf ON f.rowid = pf.fk_facture";
if (empty($sqlwhere)) {
$sqlwhere = ' WHERE ';
} else {
$sqlwhere .= " AND";
}
$sqlwhere .= " f.fk_statut > 0";
$sqlwhere .= " AND pf.fk_paiement IS NULL";
}
if (in_array('payments', $filter) || in_array('bank', $filter)) {
$sql .= ", " . MAIN_DB_PREFIX . "paiement_facture as pf, " . MAIN_DB_PREFIX . "paiement as p";
if (in_array('bank', $filter)) {
$sql .= ", " . MAIN_DB_PREFIX . "bank as b";
}
if (empty($sqlwhere)) {
$sqlwhere = ' WHERE ';
} else {
$sqlwhere .= " AND";
}
$sqlwhere .= " f.fk_statut > 0";
$sqlwhere .= " AND f.rowid = pf.fk_facture";
$sqlwhere .= " AND pf.fk_paiement = p.rowid";
if (in_array('payments', $filter)) {
$sqlwhere .= " AND p.datep >= '" . $db->idate($paymentdateafter) . "'";
$sqlwhere .= " AND p.datep <= '" . $db->idate($paymentdatebefore) . "'";
}
if (in_array('bank', $filter)) {
$sqlwhere .= " AND p.fk_bank = b.rowid";
$sqlwhere .= " AND b.fk_account = " . $paymentbankid;
}
$sqlorder = " ORDER BY p.datep ASC";
}
if (in_array('nodeposit', $filter)) {
if (empty($sqlwhere)) {
$sqlwhere = ' WHERE ';
} else {
$sqlwhere .= " AND";
}
$sqlwhere .= ' type <> 3';
}
if (in_array('noreplacement', $filter)) {
if (empty($sqlwhere)) {
$sqlwhere = ' WHERE ';
} else {
$sqlwhere .= " AND";
}
$sqlwhere .= ' type <> 1';
}
if (in_array('nocreditnote', $filter)) {
if (empty($sqlwhere)) {
$sqlwhere = ' WHERE ';
} else {
$sqlwhere .= " AND";
}
$sqlwhere .= ' type <> 2';
}
if (in_array('excludethirdparties', $filter) && is_array($thirdpartiesid)) {
if (empty($sqlwhere)) {
//.........这里部分代码省略.........
示例5: show_actions_done
/**
* Show html area with actions done
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
* @param Object $object Object third party or member
* @param Contact $objcon Object contact
* @param int $noprint Return string but does not output it
* @return mixed Return html part or void if noprint is 1
* TODO change function to be able to list event linked to an object.
*/
function show_actions_done($conf, $langs, $db, $object, $objcon = '', $noprint = 0)
{
global $bc, $user;
// Check parameters
if (!is_object($object)) {
dol_print_error('', 'BadParameter');
}
$out = '';
$histo = array();
$numaction = 0;
$now = dol_now('tzuser');
if (!empty($conf->agenda->enabled)) {
// Recherche histo sur actioncomm
$sql = "SELECT a.id, a.label,";
$sql .= " a.datep as dp,";
$sql .= " a.datep2 as dp2,";
$sql .= " a.note, a.percent,";
$sql .= " a.fk_element, a.elementtype,";
$sql .= " a.fk_user_author, a.fk_contact,";
$sql .= " c.code as acode, c.libelle,";
$sql .= " u.login, u.rowid as user_id";
if (get_class($object) == 'Adherent') {
$sql .= ", m.lastname, m.firstname";
}
if (get_class($object) == 'Societe') {
$sql .= ", sp.lastname, sp.firstname";
}
$sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a";
if (get_class($object) == 'Adherent') {
$sql .= ", " . MAIN_DB_PREFIX . "adherent as m";
}
if (get_class($object) == 'Societe') {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
}
$sql .= " WHERE u.rowid = a.fk_user_author";
$sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")";
if (get_class($object) == 'Adherent') {
$sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
}
if (get_class($object) == 'Adherent' && $object->id) {
$sql .= " AND a.fk_element = " . $object->id;
}
if (get_class($object) == 'Societe' && $object->id) {
$sql .= " AND a.fk_soc = " . $object->id;
}
if (is_object($objcon) && $objcon->id) {
$sql .= " AND a.fk_contact = " . $objcon->id;
}
$sql .= " AND c.id=a.fk_action";
$sql .= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '" . $db->idate($now) . "'))";
$sql .= " ORDER BY a.datep DESC, a.id DESC";
dol_syslog("company.lib::show_actions_done sql=" . $sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
$var = true;
while ($i < $num) {
$obj = $db->fetch_object($resql);
$histo[$numaction] = array('type' => 'action', 'id' => $obj->id, 'datestart' => $db->jdate($obj->dp), 'date' => $db->jdate($obj->dp2), 'note' => $obj->label, 'percent' => $obj->percent, 'acode' => $obj->acode, 'libelle' => $obj->libelle, 'userid' => $obj->user_id, 'login' => $obj->login, 'contact_id' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'fk_element' => $obj->fk_element, 'elementtype' => $obj->elementtype);
$numaction++;
$i++;
}
} else {
dol_print_error($db);
}
}
if (!empty($conf->mailing->enabled) && !empty($objcon->email)) {
$langs->load("mails");
// Recherche histo sur mailing
$sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,";
$sql .= " 'AC_EMAILING' as acode,";
$sql .= " u.rowid as user_id, u.login";
// User that valid action
$sql .= " FROM " . MAIN_DB_PREFIX . "mailing as m, " . MAIN_DB_PREFIX . "mailing_cibles as mc, " . MAIN_DB_PREFIX . "user as u";
$sql .= " WHERE mc.email = '" . $db->escape($objcon->email) . "'";
// Search is done on email.
$sql .= " AND mc.statut = 1";
$sql .= " AND u.rowid = m.fk_user_valid";
$sql .= " AND mc.fk_mailing=m.rowid";
$sql .= " ORDER BY mc.date_envoi DESC, m.rowid DESC";
dol_syslog("company.lib::show_actions_done sql=" . $sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
$var = true;
while ($i < $num) {
//.........这里部分代码省略.........
示例6: migrate_project_task_actors
/**
* Migration de la table llx_projet_task_actors vers llx_element_contact
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_project_task_actors($db, $langs, $conf)
{
dolibarr_install_syslog("upgrade2::migrate_project_task_actors");
print '<tr><td colspan="4">';
print '<br>';
print '<b>' . $langs->trans('MigrationProjectTaskActors') . "</b><br>\n";
if ($db->DDLInfoTable(MAIN_DB_PREFIX . "projet_task_actors")) {
$error = 0;
$db->begin();
$sql = "SELECT fk_projet_task, fk_user FROM " . MAIN_DB_PREFIX . "projet_task_actors";
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
$sql2 = "INSERT INTO " . MAIN_DB_PREFIX . "element_contact (";
$sql2 .= "datecreate";
$sql2 .= ", statut";
$sql2 .= ", element_id";
$sql2 .= ", fk_c_type_contact";
$sql2 .= ", fk_socpeople";
$sql2 .= ") VALUES (";
$sql2 .= "'" . $db->idate(dol_now()) . "'";
$sql2 .= ", '4'";
$sql2 .= ", " . $obj->fk_projet_task;
$sql2 .= ", '180'";
$sql2 .= ", " . $obj->fk_user;
$sql2 .= ")";
$resql2 = $db->query($sql2);
if (!$resql2) {
$error++;
dol_print_error($db);
}
print ". ";
$i++;
}
}
if ($error == 0) {
$sqlDrop = "DROP TABLE " . MAIN_DB_PREFIX . "projet_task_actors";
if ($db->query($sqlDrop)) {
$db->commit();
} else {
$db->rollback();
}
} else {
$db->rollback();
}
} else {
dol_print_error($db);
$db->rollback();
}
} else {
print $langs->trans('AlreadyDone') . "<br>\n";
}
print '</td></tr>';
}
示例7: print_projecttasks_array
/**
* Return HTML table with list of projects and number of opened tasks
*
* @param DoliDB $db Database handler
* @param Form $form Object form
* @param int $socid Id thirdparty
* @param int $projectsListId Id of project i have permission on
* @param int $mytasks Limited to task i am contact to
* @param int $statut -1=No filter on statut, 0 or 1 = Filter on status
* @param array $listofoppstatus List of opportunity status
* @return void
*/
function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array())
{
global $langs, $conf, $user, $bc;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$projectstatic = new Project($db);
$sortfield = '';
$sortorder = '';
$project_year_filter = 0;
$title = $langs->trans("Projects");
if (strcmp($statut, '') && $statut >= 0) {
$title = $langs->trans("Projects") . ' ' . $langs->trans($projectstatic->statuts_long[$statut]);
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($title, "index.php", "", "", "", "", $sortfield, $sortorder);
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
print_liste_field_titre($langs->trans("OpportunityAmount"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("OpportunityStatus"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
}
print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
print "</tr>\n";
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount, COUNT(DISTINCT t.rowid) as nb";
// We use DISTINCT here because line can be doubled if task has 2 links to same user
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as p";
if ($mytasks) {
$sql .= ", " . MAIN_DB_PREFIX . "projet_task as t";
$sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec";
$sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc";
} else {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet";
}
$sql .= " WHERE p.entity = " . $conf->entity;
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
if ($socid) {
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")";
}
if ($mytasks) {
$sql .= " AND p.rowid = t.fk_projet";
$sql .= " AND ec.element_id = t.rowid";
$sql .= " AND ctc.rowid = ec.fk_c_type_contact";
$sql .= " AND ctc.element = 'project_task'";
$sql .= " AND ec.fk_socpeople = " . $user->id;
}
if ($statut >= 0) {
$sql .= " AND p.fk_statut = " . $statut;
}
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
if ($project_year_filter != "*") {
if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
$project_year_filter = date("Y");
}
$sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")";
$sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")";
}
}
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount";
$sql .= " ORDER BY p.title, p.ref";
$var = true;
$resql = $db->query($sql);
if ($resql) {
$total_task = 0;
$total_opp_amount = 0;
$ponderated_opp_amount = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($resql);
$projectstatic->id = $objp->projectid;
$projectstatic->user_author_id = $objp->fk_user_creat;
$projectstatic->public = $objp->public;
// Check is user has read permission on project
$userAccess = $projectstatic->restrictedProjectArea($user);
if ($userAccess >= 0) {
$var = !$var;
print "<tr " . $bc[$var] . ">";
print '<td class="nowrap">';
$projectstatic->ref = $objp->ref;
print $projectstatic->getNomUrl(1);
print ' - ' . dol_trunc($objp->title, 24) . '</td>';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
print '<td align="right">';
if ($objp->opp_amount) {
print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
//.........这里部分代码省略.........
示例8: print_projecttasks_array
/**
* Return HTML table with list of projects and number of opened tasks
*
* @param DoliDB $db Database handler
* @param int $socid Id thirdparty
* @param int $projectsListId Id of project i have permission on
* @param int $mytasks Limited to task i am contact to
* @param int $statut -1=No filter on statut, 0 or 1 = Filter on status
* @return void
*/
function print_projecttasks_array($db, $socid, $projectsListId, $mytasks = 0, $statut = -1)
{
global $langs, $conf, $user, $bc;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$projectstatic = new Project($db);
$sortfield = '';
$sortorder = '';
$project_year_filter = 0;
$title = $langs->trans("Project");
if ($statut == 0) {
$title = $langs->trans("ProjectDraft");
}
if ($statut == 1) {
$title = $langs->trans("Project") . ' (' . $langs->trans("Validated") . ')';
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($title, "index.php", "", "", "", "", $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
print "</tr>\n";
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, COUNT(t.rowid) as nb";
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as p";
if ($mytasks) {
$sql .= ", " . MAIN_DB_PREFIX . "projet_task as t";
$sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec";
$sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc";
} else {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet";
}
$sql .= " WHERE p.entity = " . $conf->entity;
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
if ($socid) {
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")";
}
if ($mytasks) {
$sql .= " AND p.rowid = t.fk_projet";
$sql .= " AND ec.element_id = t.rowid";
$sql .= " AND ctc.rowid = ec.fk_c_type_contact";
$sql .= " AND ctc.element = 'project_task'";
$sql .= " AND ec.fk_socpeople = " . $user->id;
}
if ($statut >= 0) {
$sql .= " AND p.fk_statut = " . $statut;
}
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
if ($project_year_filter != "*") {
if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
//
$project_year_filter = date("Y");
}
$sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")";
$sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")";
}
}
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut";
$sql .= " ORDER BY p.title, p.ref";
$var = true;
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($resql);
$projectstatic->id = $objp->projectid;
$projectstatic->user_author_id = $objp->fk_user_creat;
$projectstatic->public = $objp->public;
// Check is user has read permission on project
$userAccess = $projectstatic->restrictedProjectArea($user);
if ($userAccess >= 0) {
$var = !$var;
print "<tr " . $bc[$var] . ">";
print '<td class="nowrap">';
$projectstatic->ref = $objp->ref;
print $projectstatic->getNomUrl(1);
print ' - ' . dol_trunc($objp->title, 24) . '</td>';
print '<td align="right">' . $objp->nb . '</td>';
$projectstatic->statut = $objp->fk_statut;
print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>';
print "</tr>\n";
}
$i++;
}
$db->free($resql);
} else {
dol_print_error($db);
}
print "</table>";
//.........这里部分代码省略.........