$pdf->AddCol('item', '50%', 'Item', 'L');
        $pdf->AddCol('pr_qty', '15%', 'Quantity', 'R');
        $pdf->AddCol('pr_rate', '15%', 'Rate', 'R');
        $pdf->AddCol('amt', '15%', 'Amount', 'R');
        $pdf->Table($data, $prop);
        $_cMargin = $pdf->cMargin;
        $pdf->cMargin = $prop['padding'];
        $pdf->SetFont($prop['thfont'][0], $prop['thfont'][1], $prop['thfont'][2]);
        $width = $pdf->w - $pdf->lMargin - $pdf->rMargin;
        $cellSize = 0.01 * $width;
        $pdf->Cell($cellSize * 45, 6, 'Total', 0, 0, 'C', false);
        $pdf->Cell($cellSize * 20, 6, number_format($total['qty']), 0, 0, 'R', false);
        $pdf->Cell($cellSize * 15, 6, '', 0, 0, 'L', false);
        $pdf->Cell($cellSize * 20, 6, number_format($total['amt']), 0, 0, 'R', false);
        $pdf->Ln();
        $pdf->Cell($cellSize * 100, 5, convertCurrency($total['amt'], getCurrencySymbol($_SESSION['company_id'])) . " only", 0, 0, 'L');
        $pdf->Ln();
        $pdf->cMargin = $_cMargin;
    }
    $mysqli->close();
    $pdf->Output("purchase_return.pdf", "D");
} else {
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<link rel="shortcut icon" href="../images/logo_icon.gif">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="../stylesheets/style.css" rel="stylesheet" type="text/css" />
	<title><?php 
    echo $_SESSION['companyname'];
Exemple #2
0
]
                },
                yAxis: {
                    labels: {
                        formatter: function() {
                            var value = this.value,
                                ret;
                            if (value > 1000000) {
                                ret = (value / 1000000) +'M';
                            } else if (value > 1000) {
                                ret = (value / 1000) +'K';
                            } else {
                                ret = value;
                            }
                            return '<?php 
    echo getCurrencySymbol($_GET['company_id']);
    ?>
 ' + ret;
                        }
                    },
                    title: {
                        text: 'Amount'
                    },
                    min: <?php 
    echo $min;
    ?>
,
                    max: <?php 
    echo $max;
    ?>
                },
Exemple #3
0
function get_service_list_values($id, $modulename, $sessionid, $only_mine = 'true')
{
    require_once 'modules/Services/Services.php';
    require_once 'include/utils/UserInfoUtil.php';
    $adb = PearDatabase::getInstance();
    $log = vglobal('log');
    $log->debug("Entering customer portal Function get_service_list_values");
    $check = checkModuleActive($modulename);
    if ($check == false) {
        return array("#MODULE INACTIVE#");
    }
    $user = new Users();
    $userid = getPortalUserid();
    $current_user = $user->retrieveCurrentUserInfoFromFile($userid);
    //To avoid SQL injection we are type casting as well as bound the id variable
    $id = (int) vtlib_purify($id);
    $entity_ids_list = array();
    $show_all = show_all($modulename);
    if (!validateSession($id, $sessionid)) {
        return null;
    }
    if ($only_mine == 'true' || $show_all == 'false') {
        array_push($entity_ids_list, $id);
    } else {
        $contactquery = "SELECT contactid, parentid FROM vtiger_contactdetails " . " INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_contactdetails.contactid" . " AND vtiger_crmentity.deleted = 0 " . " WHERE (parentid = (SELECT parentid FROM vtiger_contactdetails WHERE contactid = ?)  AND parentid != 0) OR contactid = ?";
        $contactres = $adb->pquery($contactquery, array($id, $id));
        $no_of_cont = $adb->num_rows($contactres);
        for ($i = 0; $i < $no_of_cont; $i++) {
            $cont_id = $adb->query_result($contactres, $i, 'contactid');
            $acc_id = $adb->query_result($contactres, $i, 'parentid');
            if (!in_array($cont_id, $entity_ids_list)) {
                $entity_ids_list[] = $cont_id;
            }
            if (!in_array($acc_id, $entity_ids_list) && $acc_id != '0') {
                $entity_ids_list[] = $acc_id;
            }
        }
    }
    $focus = new Services();
    $focus->filterInactiveFields('Services');
    foreach ($focus->list_fields as $fieldlabel => $values) {
        foreach ($values as $table => $fieldname) {
            $fields_list[$fieldlabel] = $fieldname;
        }
    }
    $fields_list['Related To'] = 'entityid';
    $query = array();
    $params = array();
    $query[] = "select vtiger_service.*," . "case when vtiger_crmentityrel.crmid != vtiger_service.serviceid then vtiger_crmentityrel.crmid else vtiger_crmentityrel.relcrmid end as entityid, " . "'' as setype from vtiger_service " . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_service.serviceid " . "left join vtiger_crmentityrel on (vtiger_crmentityrel.relcrmid=vtiger_service.serviceid or vtiger_crmentityrel.crmid=vtiger_service.serviceid) " . "where vtiger_crmentity.deleted = 0 and " . "( vtiger_crmentityrel.crmid in (" . generateQuestionMarks($entity_ids_list) . ") OR " . "(vtiger_crmentityrel.relcrmid in (" . generateQuestionMarks($entity_ids_list) . ") AND vtiger_crmentityrel.module = 'Services')" . ")";
    $params[] = array($entity_ids_list, $entity_ids_list);
    $checkQuotes = checkModuleActive('Quotes');
    if ($checkQuotes == true) {
        $query[] = "select distinct vtiger_service.*,\n\t\t\tvtiger_quotes.accountid as entityid,\n\t\t\t'Accounts' as setype\n\t\t\tfrom vtiger_quotes INNER join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_quotes.quoteid\n\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_quotes.quoteid\n\t\t\tleft join vtiger_service on vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\twhere vtiger_inventoryproductrel.productid = vtiger_service.serviceid AND vtiger_crmentity.deleted=0 and accountid in  (" . generateQuestionMarks($entity_ids_list) . ")";
        $params[] = array($entity_ids_list);
    }
    $checkInvoices = checkModuleActive('Invoice');
    if ($checkInvoices == true) {
        $query[] = "select distinct vtiger_service.*, vtiger_invoice.accountid as entityid, 'Accounts' as setype\n\t\t\tfrom vtiger_invoice\n\t\t\tINNER join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_invoice.invoiceid\n\t\t\tleft join vtiger_inventoryproductrel on vtiger_inventoryproductrel.id=vtiger_invoice.invoiceid\n\t\t\tleft join vtiger_service on vtiger_service.serviceid = vtiger_inventoryproductrel.productid\n\t\t\twhere vtiger_inventoryproductrel.productid = vtiger_service.serviceid AND vtiger_crmentity.deleted=0 and accountid in (" . generateQuestionMarks($entity_ids_list) . ")";
        $params[] = array($entity_ids_list, $entity_ids_list);
    }
    $ServicesfieldVisibilityPermissions = array();
    foreach ($fields_list as $fieldlabel => $fieldname) {
        $ServicesfieldVisibilityPermissions[$fieldname] = getFieldVisibilityPermission('Services', $current_user->id, $fieldname);
    }
    $fieldValuesToRound = array('unit_price', 'commissionrate');
    for ($k = 0; $k < count($query); $k++) {
        $res[$k] = $adb->pquery($query[$k], $params[$k]);
        $noofdata[$k] = $adb->num_rows($res[$k]);
        if ($noofdata[$k] == 0) {
            $output[$k][$modulename]['data'] = '';
        }
        for ($j = 0; $j < $noofdata[$k]; $j++) {
            $i = 0;
            foreach ($fields_list as $fieldlabel => $fieldname) {
                $fieldper = $ServicesfieldVisibilityPermissions[$fieldname];
                if ($fieldper == '1' && $fieldname != 'entityid') {
                    continue;
                }
                $output[$k][$modulename]['head'][0][$i]['fielddata'] = Vtiger_Language_Handler::getTranslatedString($fieldlabel, 'Services', vglobal('default_language'));
                $fieldvalue = $adb->query_result($res[$k], $j, $fieldname);
                $fieldid = $adb->query_result($res[$k], $j, 'serviceid');
                if (in_array($fieldname, $fieldValuesToRound)) {
                    $fieldvalue = round($fieldvalue, 2);
                }
                if ($fieldname == 'entityid') {
                    $crmid = $fieldvalue;
                    $module = $adb->query_result($res[$k], $j, 'setype');
                    if ($module == '') {
                        $module = $adb->query_result($adb->pquery("SELECT setype FROM vtiger_crmentity WHERE crmid = ?", array($crmid)), 0, 'setype');
                    }
                    if ($crmid != '' && $module != '') {
                        $fieldvalues = getEntityName($module, array($crmid));
                        if ($module == 'Contacts') {
                            $fieldvalue = '<a href="index.php?module=Contacts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>';
                        } elseif ($module == 'Accounts') {
                            $fieldvalue = '<a href="index.php?module=Accounts&action=index&id=' . $crmid . '">' . $fieldvalues[$crmid] . '</a>';
                        }
                    } else {
                        $fieldvalue = '';
                    }
                }
                if ($fieldname == 'servicename') {
                    $fieldvalue = '<a href="index.php?module=Services&action=index&id=' . $fieldid . '">' . $fieldvalue . '</a>';
                }
                if ($fieldname == 'unit_price') {
                    $sym = getCurrencySymbol($res[$k], $j, 'currency_id');
                    $fieldvalue = $sym . $fieldvalue;
                }
                $output[$k][$modulename]['data'][$j][$i]['fielddata'] = $fieldvalue;
                $i++;
            }
        }
    }
    $log->debug("Exiting customerportal function get_product_list_values.....");
    return $output;
}
         $pdf->printHeader();
         $cMargin = $pdf->cMargin;
         $pdf->cMargin = $prop['padding'];
         $pdf->AddCol('sno', '6%', 'S.No.', 'L');
         $pdf->AddCol('cno', '6%', 'Cno', 'L');
         $pdf->AddCol('manufacturer_no', '15%', 'Part No', 'L');
         $pdf->AddCol('i_name', '40%', 'Description', 'L');
         $pdf->AddCol('raw_qty', '7%', 'Qty', 'R');
         $pdf->AddCol('sales_rate', '8%', 'Rate', 'R');
         $pdf->AddCol('discount_value', '8%', 'Discount', 'R');
         $pdf->AddCol('net', '10%', 'Amount', 'R');
         $pdf->Table($ddata, $prop);
         $pdf->SetFont($prop['thfont'][0], $prop['thfont'][1], $prop['thfont'][2]);
         $cellSize = 1 / 100 * $pdf->TableWidth;
         $pdf->SetX($pdf->lMargin);
         $pdf->Cell($cellSize * 75, 5, convertCurrency($net, getCurrencySymbol($_SESSION['company_id'])) . " only", 0, 0, 'L');
         $pdf->Cell($cellSize * 25, 5, number_format($net, 0), 0, 0, 'R');
         $pdf->Ln();
         $pdf->cMargin = $cMargin;
     }
 }
 $mysqli->close();
 $fileName = "sales_invoice";
 if (isset($_GET['invoice']) && strlen($_GET['invoice']) > 0) {
     $fileName .= "_{$_GET['invoice']}";
 } else {
     if (isset($_GET['party']) && strlen($_GET['party']) > 0) {
         $fileName .= "_{$_GET['party']}";
     }
 }
 $pdf->Output("{$fileName}.pdf", "D");
Exemple #5
0
 /**
  *  Charge les donnees en memoire pour affichage ulterieur
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $conf, $user, $langs, $db;
     $totalMnt = 0;
     $totalnb = 0;
     include_once DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php";
     include_once DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php";
     include_once DOL_DOCUMENT_ROOT . "/commande/class/commande.class.php";
     $facturestatic = new Facture($db);
     $propalstatic = new Propal($db);
     $commandestatic = new Commande($db);
     $textHead = $langs->trans("Activity") . "&nbsp;" . date("Y");
     $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead));
     // list the summary of the bills
     if ($conf->facture->enabled && $user->rights->facture->lire) {
         $sql = "SELECT f.paye, f.fk_statut, sum(f.total_ttc) as Mnttot, count(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f";
         $sql .= " WHERE f.entity = " . $conf->entity;
         $sql .= " AND f.fk_soc = s.rowid";
         $sql .= " AND (DATE_FORMAT(f.datef,'%Y') = " . date("Y") . " or paye=0)";
         $sql .= " GROUP BY f.paye, f.fk_statut ";
         $sql .= " ORDER BY f.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $now = dol_now();
             $i = 0;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . "&nbsp;" . $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 0));
                 if ($objp->fk_statut == 0) {
                     // draft
                     $billurl = "viewstatut=0&paye=0";
                 } elseif ($objp->fk_statut == 1) {
                     // unpaid
                     $billurl = "viewstatut=1&paye=0";
                 } else {
                     // paid for current year
                     $billurl = "viewstatut=2&paye=1";
                 }
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills");
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . "&nbsp;" . getCurrencySymbol($conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices"));
             }
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     }
     // list the summary of the orders
     if ($conf->commande->enabled && $user->rights->commande->lire) {
         $sql = "SELECT c.fk_statut,c.facture, sum(c.total_ttc) as Mnttot, count(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c";
         $sql .= " WHERE c.entity = " . $conf->entity;
         $sql .= " AND c.fk_soc = s.rowid";
         $sql .= " AND c.facture=0";
         $sql .= " GROUP BY c.fk_statut";
         $sql .= " ORDER BY c.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_order');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . "&nbsp;" . $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 0));
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/commande/liste.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . "&nbsp;" . getCurrencySymbol($conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $i++;
             }
         }
     }
     // list the summary of the propals
     if ($conf->propal->enabled && $user->rights->propal->lire) {
         $sql = "SELECT p.fk_statut, sum(p.total) as Mnttot, count(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p";
         $sql .= " WHERE p.entity = " . $conf->entity;
         $sql .= " AND p.fk_soc = s.rowid";
         $sql .= " AND DATE_FORMAT(p.datep,'%Y') = " . date("Y");
         $sql .= " AND p.date_cloture IS NULL ";
         // just unclosed
         $sql .= " GROUP BY p.fk_statut";
         $sql .= " ORDER BY p.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_propal');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . "&nbsp;" . $propalstatic->LibStatut($objp->fk_statut, 0));
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . "&nbsp;" . getCurrencySymbol($conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3));
                 $i++;
             }
         }
     }
     // Add the sum in the bottom of the boxes
     $this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total") . "&nbsp;" . $textHead);
     $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' '));
     $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => number_format($totalMnt, 0, ',', ' ') . "&nbsp;" . getCurrencySymbol($conf->currency));
     $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => "");
     $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => "");
 }
Exemple #6
0
 } else {
     print img_warning() . ' <font class="error">' . $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")) . '</font>';
 }
 print '</td></tr>';
 $var = !$var;
 print '<tr ' . $bc[$var] . '><td>' . $langs->trans("State") . '</td><td>';
 if ($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT) {
     print getState($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT);
 } else {
     print '&nbsp;';
 }
 print '</td></tr>';
 $var = !$var;
 print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("CompanyCurrency") . '</td><td>';
 print currency_name($conf->currency, 1);
 print ' (' . getCurrencySymbol($conf->currency) . ')';
 print '</td></tr>';
 $var = !$var;
 print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Tel") . '</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL, $mysoc->country_code) . '</td></tr>';
 $var = !$var;
 print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Fax") . '</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX, $mysoc->country_code) . '</td></tr>';
 $var = !$var;
 print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Mail") . '</td><td>' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL, 0, 0, 0, 80) . '</td></tr>';
 // Web
 $var = !$var;
 print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Web") . '</td><td>' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB, '_blank', 80) . '</td></tr>';
 // Barcode
 if (!empty($conf->barcode->enabled)) {
     $var = !$var;
     print '<tr ' . $bc[$var] . '><td width="35%">' . $langs->trans("Gencod") . '</td><td>' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '</td></tr>';
 }
Exemple #7
0
 /**
  * Saves the content item an edit form submit
  *
  * @todo
  */
 function save()
 {
     $app = JFactory::getApplication();
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     $user = JFactory::getUser();
     $content = JTable::getInstance('contents', 'AdsmanagerTable');
     $this->addModelPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_adsmanager' . DS . 'models');
     $configurationmodel = $this->getModel("configuration");
     $contentmodel = $this->getModel("content");
     $usermodel = $this->getModel("user");
     $fieldmodel = $this->getModel("field");
     $conf = $configurationmodel->getConfiguration();
     $plugins = $fieldmodel->getPlugins();
     $id = JRequest::getInt('id', 0);
     // New or Update
     if ($id != 0) {
         $content->load($id);
         if ($content == null || $content->userid != $user->id) {
             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'));
         }
         $isUpdateMode = 1;
         if ($conf->update_validation == 1) {
             $redirect_text = JText::_('ADSMANAGER_INSERT_SUCCESSFULL_CONFIRM');
         } else {
             $redirect_text = JText::_('ADSMANAGER_AD_UPDATED');
         }
     } else {
         $isUpdateMode = 0;
         if ($conf->auto_publish == 0) {
             $redirect_text = JText::_('ADSMANAGER_INSERT_SUCCESSFULL_CONFIRM');
         } else {
             $redirect_text = JText::_('ADSMANAGER_INSERT_SUCCESSFULL_PUBLISH');
         }
     }
     //Check Max Ads by User
     $nbcats = $conf->nbcats;
     if (function_exists("getMaxCats")) {
         $nbcats = getMaxCats($conf->nbcats);
     }
     if ($nbcats <= 1) {
         if (function_exists("checkAuthorisedNumberAds")) {
             $limitAds = checkAuthorisedNumberAds($contentmodel, JRequest::getInt('category', 0));
             if ($limitAds !== true) {
                 $redirect_text = sprintf(JText::_('ADSMANAGER_MAX_NUM_ADS_PER_CATEGORY_REACHED'), $limitAds);
                 $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
             }
         } else {
             if (JRequest::getInt('category', 0) != 0) {
                 $category = JRequest::getInt('category', 0);
                 // Need to check limit only for new ad and if category of ad is changed
                 if ($isUpdateMode == 0 || !in_array($category, $contentmodel->getContentCategories($id))) {
                     $nb = $contentmodel->getNbContentsOfUser($user->id, $category);
                     //TODO : check authorised number for multi-categories
                     $categoriesModel = $this->getModel("category");
                     $category = $categoriesModel->getCategory($category);
                     if ($category->limitads !== "" && $category->limitads !== null) {
                         if ($nb >= $category->limitads && $category->limitads != -1) {
                             $redirect_text = sprintf(JText::_('ADSMANAGER_MAX_NUM_ADS_PER_CATEGORY_REACHED'), $category->limitads);
                             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
                         }
                     }
                 }
             }
         }
     }
     if ($id == 0 && $user->id != "0" && $conf->nb_ads_by_user != -1) {
         $nb = $contentmodel->getNbContentsOfUser($user->id);
         if ($nb >= $conf->nb_ads_by_user) {
             $redirect_text = sprintf(JText::_('ADSMANAGER_MAX_NUM_ADS_REACHED'), $conf->nb_ads_by_user);
             $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
         }
     }
     //check if user can post an ad in the category selected
     //TODO : If multiple category
     if (version_compare(JVERSION, '1.6', 'ge')) {
         if ($nbcats <= 1) {
             $authorisedCategory = TPermissions::getAuthorisedCategories('write');
             if (array_search(JRequest::getInt('category', 0), $authorisedCategory) === false) {
                 $redirect_text = sprintf(JText::_('ADSMANAGER_FORBIDDEN_CATEGORY'), $conf->nb_ads_by_user);
                 $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
             }
         }
     }
     $current = clone $content;
     $content->bindContent(JRequest::get('post'), JRequest::get('files'), $conf, $this->getModel("adsmanager"), $plugins);
     if (function_exists('bindPaidSystemContent')) {
         bindPaidSystemContent($content, JRequest::get('post'), JRequest::get('files'), $conf, $this->getModel("adsmanager"));
     }
     $content->current = $current;
     $errors = $content->getErrors();
     if (count($errors) > 0) {
         $this->reloadForm($content);
     }
     if ($conf->metadata_mode == 'backendonly') {
         $content->metadata_description = JRequest::getVar('ad_text', '');
         $content->metadata_keywords = str_replace(" ", ",", JRequest::getVar('ad_headline', ''));
     }
     $errorMsg = null;
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('adsmanagercontent');
     try {
         $results = $dispatcher->trigger('ADSonContentBeforeSave', array());
     } catch (Exception $e) {
         $errorMsg = $e->getMessage();
         $this->reloadForm($content, $errorMsg);
     }
     //Creation of account if needed
     if ($conf->submission_type == 0 && $user->id == 0) {
         $username = JRequest::getVar('username', "");
         $password = JRequest::getVar('password', "");
         $email = JRequest::getVar('email', "");
         $errorMsg = $usermodel->checkAccount($username, $password, $email, $userid, $conf);
         if (isset($errorMsg)) {
             $this->reloadForm($content, $errorMsg);
         }
         $user->id = $userid;
     }
     //Valid account or visitor are allowed to post
     if ($user->id != 0 || $conf->submission_type == 2) {
         $content->userid = $user->id;
     } else {
         //trying to save ad, without being registered
         return;
     }
     if (function_exists("getPaidSystemMode")) {
         $mode = getPaidSystemMode();
     } else {
         $mode = "nopaidsystem";
     }
     $total = 0;
     switch ($mode) {
         case "credits":
             computeCost($total, $items, $content, $conf, $isUpdateMode);
             if ($total == 0) {
                 $content->save();
             } else {
                 if (checkCredits($total, $user->id) == true) {
                     //TODO ?
                     //generateBill($content,$total,$items,$mode,"ok");
                     removeCredits($user->id, $total, $items, 'Adsmanager');
                     $content->save();
                 } else {
                     $errorMsg = sprintf(JText::_('PAIDSYSTEM_NOT_ENOUGH_CREDITS'), strtolower(getCurrencySymbol()));
                     $this->reloadForm($content, $errorMsg);
                 }
             }
             break;
         case "payperad":
             $adid = $content->savePending();
             $content->isPending = true;
             computeCost($total, $items, $content, $conf, $isUpdateMode);
             if ($total == 0) {
                 $content->save();
             } else {
                 $invoice_id = generateBill($content, $items, $adid);
             }
             break;
         case "nopaidsystem":
             $content->save();
             break;
     }
     // We need to put "pending or new values" in the $content obj instead of $content->data
     $content->map();
     if ($mode == "payperad" && $total > 0 && $isUpdateMode == 0) {
         if (@$conf->preview == 1) {
             $app->redirect('index.php?option=com_adsmanager&view=preview&id=' . $adid);
         } else {
             Invoicing::redirectToPayment($invoice_id);
             //$app->redirect( 'index.php?option=com_paidsystem&view=payment');
         }
     } else {
         if (@$conf->preview == 1 && JRequest::getInt('pending', 0) == 1) {
             $app->redirect('index.php?option=com_adsmanager&view=preview&id=' . $adid);
         } else {
             if ($mode == "payperad" && $total > 0 && $isUpdateMode == 1) {
                 Invoicing::redirectToPayment($invoice_id);
             } else {
                 $cache =& JFactory::getCache('com_adsmanager');
                 $cache->clean();
                 if ($isUpdateMode == 0) {
                     if ($conf->send_email_on_new_to_user == 1 && $conf->auto_publish == 1) {
                         $contentmodel->sendMailToUser($conf->new_subject, $conf->new_text, $user, $content, $conf, "new");
                     } else {
                         if ($conf->send_email_waiting_validation_to_user == 1 && $conf->auto_publish == 0) {
                             $contentmodel->sendMailToUser($conf->waiting_validation_subject, $conf->waiting_validation_text, $user, $content, $conf, "waiting_validation");
                         }
                     }
                     if ($conf->email_on_waiting_validation == 1 && $conf->auto_publish == 0) {
                         if (isset($conf->admin_waiting_validation_subject) && $conf->admin_waiting_validation_text) {
                             $contentmodel->sendMailToAdmin($conf->admin_waiting_validation_subject, $conf->admin_waiting_validation_text, $user, $content, $conf, "admin_waiting_validation");
                         }
                     }
                     if ($conf->send_email_on_new == 1) {
                         $contentmodel->sendMailToAdmin($conf->admin_new_subject, $conf->admin_new_text, $user, $content, $conf, "new");
                     }
                 } else {
                     if ($conf->update_validation == 1) {
                         $contentmodel->sendMailToUser($conf->waiting_validation_subject, $conf->waiting_validation_text, $user, $content, $conf, "waiting_validation");
                     } else {
                         if ($conf->send_email_on_update_to_user == 1) {
                             $contentmodel->sendMailToUser($conf->update_subject, $conf->update_text, $user, $content, $conf, "update");
                         }
                     }
                     if ($conf->email_on_waiting_validation == 1 && $conf->update_validation == 1) {
                         if (isset($conf->admin_waiting_validation_subject) && $conf->admin_waiting_validation_text) {
                             $contentmodel->sendMailToAdmin($conf->admin_waiting_validation_subject, $conf->admin_waiting_validation_text, $user, $content, $conf, "admin_waiting_validation");
                         }
                     }
                     if ($conf->send_email_on_update == 1) {
                         $contentmodel->sendMailToAdmin($conf->admin_update_subject, $conf->admin_update_text, $user, $content, $conf, "update");
                     }
                 }
                 JPluginHelper::importPlugin('adsmanagercontent');
                 try {
                     $results = $dispatcher->trigger('ADSonContentAfterSave', array($content, $isUpdateMode, $conf));
                 } catch (Exception $e) {
                     $errorMsg = $e->getMessage();
                 }
                 //Redirect
                 if ($conf->submission_type == 2) {
                     $app->redirect(TRoute::_('index.php?option=com_adsmanager&view=list'), $redirect_text, 'message');
                 } else {
                     $app->redirect(TLink::getMyAdsLink(), $redirect_text, 'message');
                 }
             }
         }
     }
 }
/**
 * Get related SalesOrder items
 * 
 * @param int $crmid    salesorder id
 * @return array        $array[index][fieldname] = fieldvalue
 */
function getRelatedSalesOrderItems($crmid)
{
    global $adb, $log;
    $log->debug("Entering customer portal function getRelatedSalesOrderItems");
    $module = 'Products';
    $sc_info = array();
    if (vtlib_isModuleActive($module) !== true) {
        return $sc_info;
    }
    $query = "SELECT vtiger_inventoryproductrel.*, vtiger_products.* " . "FROM vtiger_inventoryproductrel " . "INNER JOIN vtiger_products ON vtiger_inventoryproductrel.productid = vtiger_products.productid " . "INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_inventoryproductrel.productid AND vtiger_crmentity.deleted = 0 " . "WHERE vtiger_inventoryproductrel.id = ?";
    $res = $adb->pquery($query, array($crmid));
    $rows = $adb->num_rows($res);
    for ($i = 0; $i < $rows; $i++) {
        $qty = $adb->query_result($res, $i, 'quantity');
        $sc_info[$i]['productid' . $adb->query_result($res, $i, 'productid')] = $qty;
        $sc_info[$i][getTranslatedString('LBL_PRODUCT_CODE', $module)] = $adb->query_result($res, $i, 'product_no');
        $sc_info[$i][getTranslatedString('LBL_PRODUCT_NAME', $module)] = $adb->query_result($res, $i, 'productname');
        $sym = getCurrencySymbol($res, $i, 'currency_id');
        $listprice = $adb->query_result($res, $i, 'listprice');
        $sc_info[$i][getTranslatedString('LBL_PB_LIST_PRICE', 'SalesOrder')] = getCurrencyValue($sym, $listprice);
        $sc_info[$i][getTranslatedString('Quantity', 'SalesOrder')] = number_format($qty);
    }
    $log->debug("Exiting customerportal function getRelatedSalesOrderItems");
    return $sc_info;
}
Exemple #9
0
            $ndata["{$user_id}"]['company_ref_id'] = $row['company_ref_id'];
            $ndata["{$user_id}"]['data'] = array();
        }
        $arr = array();
        $arr['account_name'] = $row['account_name'];
        $arr['debit_amount'] = $row['debit_amount'] * 1;
        $ndata["{$user_id}"]['data'][] = $arr;
    }
    dump($ndata);
    include_once '../../Classes/Telenor.php';
    $telenor = new Telenor('923458219245', '7264');
    //$telenor->setMask('NEXEXCEL');
    $sms_template_1 = "Dear %s %s, You have %d Cheque as of %s for a total of %s %s from\n";
    $sms_template_2 = "%s - %s %s\n";
    foreach ($ndata as $user_id => $data) {
        $currencyCode = getCurrencySymbol($data['company_ref_id']);
        $total = (double) 0;
        $sms = "";
        foreach ($data['data'] as $row) {
            $total += $row['debit_amount'];
            $sms .= sprintf($sms_template_2, $row['account_name'], $currencyCode, number_format($row['debit_amount']));
        }
        $sms = trim(sprintf($sms_template_1, $data['first_name'], $data['last_name'], count($data['data']), date("d-M-y"), $currencyCode, number_format($total)) . $sms);
        $ret = $telenor->sendSms($data['mobile_number'], $sms);
        if ($ret === false) {
            $error = $telenor->getError();
            dump($error);
        }
    }
}
$out = ob_get_contents();
Exemple #10
0
					if ('<?php 
echo $_SESSION['do_restrict'];
?>
' == 'Yes') {
                        var $item = $('#item_'+i+"_hidden");
                        var $rate = $('#inp3_'+i);
                        if ($rate.val() != '' && $rate.val() > 0) {
                            $.ajax({
                                url:  "../transaction/rates.php",
                                async: false,
                                data: "restrict=" + $item.val() + "",
                                dataType: 'json',
                                success: function(data) {
                                    if (data.restrict_rate > 0 && $rate.val() < data.restrict_rate) {
                                        err += "Rate for Item '" + item.value + " should be greater than <?php 
echo getCurrencySymbol($_SESSION['company_id']);
?>
 " + data.restrict_rate + sep;
                                        ret = false;
                                    }
                                }
                            });
                        } else {
                            err += "Please specify the rate for Item '" + item.value + "" + sep;
                            ret = false;
                        }
                    } else {
                        break;
                    }
				}
			}
Exemple #11
0
 /**
  *  Retourne la liste des devises, dans la langue de l'utilisateur
  *
  *  @param	string	$selected    preselected currency code
  *  @param  string	$htmlname    name of HTML select list
  * 	@return	void
  */
 function selectcurrency($selected = '', $htmlname = 'currency_id')
 {
     global $conf, $langs, $user;
     $langs->load("dict");
     $this->load_cache_currencies();
     $out = '';
     if ($selected == 'euro' || $selected == 'euros') {
         $selected = 'EUR';
     }
     // Pour compatibilite
     $out .= '<select class="flat" name="' . $htmlname . '">';
     foreach ($this->cache_currencies as $code_iso => $currency) {
         if ($selected && $selected == $code_iso) {
             $out .= '<option value="' . $code_iso . '" selected="selected">';
         } else {
             $out .= '<option value="' . $code_iso . '">';
         }
         $out .= $currency['label'];
         $out .= ' (' . getCurrencySymbol($code_iso) . ')';
         $out .= '</option>';
     }
     $out .= '</select>';
     if ($user->admin) {
         $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"), 1);
     }
     return $out;
 }
Exemple #12
0
                                         } else {
                                             if ($fieldlist[$field] == 'libelle' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX . 'c_input_method') {
                                                 $langs->load("orders");
                                                 $key = $langs->trans($obj->code);
                                                 $valuetoshow = $obj->code && $key != $obj->code ? $key : $obj->{$fieldlist}[$field];
                                             } else {
                                                 if ($fieldlist[$field] == 'libelle' && $tabname[$_GET["id"]] == MAIN_DB_PREFIX . 'c_shipment_mode') {
                                                     $langs->load("sendings");
                                                     $key = $langs->trans("SendingMethod" . strtoupper($obj->code));
                                                     $valuetoshow = $obj->code && $key != "SendingMethod" . strtoupper($obj->code) ? $key : $obj->{$fieldlist}[$field];
                                                 } else {
                                                     if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'pays_id') {
                                                         $showfield = 0;
                                                     } else {
                                                         if ($fieldlist[$field] == 'unicode') {
                                                             $valuetoshow = getCurrencySymbol($obj->code);
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }