Пример #1
0
 /**
  * Used to vaidate a user's credentials. (uname, pass)
  * @param	array	$creds	the uname and password passed in as an array.
  * @return 	bool
  */
 function validateCredentials($creds)
 {
     $pwent = posix_getpwnam(strtolower($creds['uname']));
     if ($pwent == false) {
         API::Error("Invalid Username/Password");
     }
     $cryptpw = crypt($creds['password'], $pwent['passwd']);
     if ($cryptpw == $pwent['passwd']) {
         API::DEBUG("[Auth_NIS::validateCredentials] returning TRUE", 8);
         $_SESSION['authed_user'] = $pwent['uid'];
         $this->authed_user = $pwent['uid'];
         $names = explode(" ", $pwent['gecos'], 2);
         $names['fname'] = $names[0];
         $names['lname'] = $names[1];
         unset($names[1]);
         unset($names[0]);
         $prefs = new Prefs();
         if ($prefs->checkUID($this->authed_user, $this->config->prefs_auto, NULL, $names)) {
             return TRUE;
         } else {
             API::Error("Username Not Valid in system. Error: 3304");
         }
     }
     return FALSE;
 }
Пример #2
0
 public function getIndex()
 {
     $categories = Prefs::getCategory()->catToSelection('title', 'title');
     $this->heads = array(array('Title', array('search' => true, 'sort' => true)), array('Creator', array('search' => true, 'sort' => false)), array('Category', array('search' => true, 'select' => $categories, 'sort' => true)), array('Tags', array('search' => true, 'sort' => true)), array('Created', array('search' => true, 'sort' => true, 'date' => true)), array('Last Update', array('search' => true, 'sort' => true, 'date' => true)));
     //print $this->model->where('docFormat','picture')->get()->toJSON();
     return parent::getIndex();
 }
Пример #3
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Prefs();
     }
     return self::$instance;
 }
 /**
  * Commentaires d'une procedure
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2008/01/30
  * @param object $rFiche Recordset de la procedure
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $rFiche = $this->getParam('rFiche');
     $mondroit = $this->getParam('mondroit');
     $daoinfo =& _dao('infosupp');
     $sql = 'SELECT * FROM module_teleprocedure_infosupp WHERE idinter=' . $rFiche->idinter . '';
     $canCheckVisible = TeleproceduresService::canMakeInTelep('CHECK_VISIBLE', $mondroit);
     $canAddComment = TeleproceduresService::canMakeInTelep('ADD_COMMENT', $mondroit);
     if (!$canCheckVisible) {
         $sql .= " AND info_message!='' AND info_message IS NOT NULL";
     }
     $sql .= " ORDER BY dateinfo ASC, idinfo ASC";
     $results = _doQuery($sql);
     // Pour chaque message on cherche les infos de son auteur
     $list = array();
     foreach ($results as $r) {
         $userInfo = Kernel::getUserInfo("ID", $r->iduser);
         //var_dump($userInfo);
         $avatar = Prefs::get('prefs', 'avatar', $r->iduser);
         $userInfo['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         $r->user = $userInfo;
         $list[] = $r;
     }
     //print_r($rFiche);
     $tpl->assign('info_message_edition', CopixZone::process('kernel|edition', array('field' => 'info_message', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('info_commentaire_edition', CopixZone::process('kernel|edition', array('field' => 'info_commentaire', 'format' => $rFiche->type_format, 'content' => '', 'width' => 350, 'height' => 135, 'options' => array('toolbarSet' => 'IconitoBasic', 'enterMode' => 'br', 'toolbarStartupExpanded' => 'false'))));
     $tpl->assign('canCheckVisible', $canCheckVisible);
     $tpl->assign('canAddComment', $canAddComment);
     $tpl->assign('list', $list);
     $tpl->assign('rFiche', $rFiche);
     $toReturn = $tpl->fetch('fiche-comms-zone.tpl');
     return true;
 }
Пример #5
0
 public function actionVersion()
 {
     if (isset($_POST['version'])) {
         Yii::app()->end(Prefs::getVersion());
     }
     Yii::app()->end('1');
 }
Пример #6
0
 public function getIndex()
 {
     $this->heads = array(array('Role', array('search' => true, 'sort' => false, 'select' => Prefs::getRole()->RoleToSelection('_id', 'rolename'))), array('Created', array('search' => true, 'sort' => true, 'date' => true)), array('Last Update', array('search' => true, 'sort' => true, 'date' => true)));
     //print $this->model->where('docFormat','picture')->get()->toJSON();
     Breadcrumbs::addCrumb('System', URL::to(strtolower($this->controller_name)));
     return parent::getIndex();
 }
Пример #7
0
 public function getIndex()
 {
     $this->heads = array(array('Full Name', array('search' => true, 'sort' => true)), array('Role', array('search' => true, 'sort' => false, 'select' => Prefs::getRole()->RoleToSelection('_id', 'rolename'))), array('Email', array('search' => true, 'sort' => true)), array('Mobile', array('search' => true, 'sort' => true)), array('Address', array('search' => true, 'sort' => true)), array('Created', array('search' => true, 'sort' => true, 'date' => true)), array('Last Update', array('search' => true, 'sort' => true, 'date' => true)));
     $this->title = 'Employees';
     $this->place_action = 'first';
     Breadcrumbs::addCrumb('HRMS', URL::to(strtolower($this->controller_name)));
     return parent::getIndex();
 }
Пример #8
0
 public function getIndex()
 {
     $categories = Prefs::getCategory()->catToSelection('title', 'title');
     $this->heads = array(array('Title', array('search' => true, 'sort' => true)), array('Status', array('search' => true, 'sort' => true)), array('Creator', array('search' => true, 'sort' => false)), array('Category', array('search' => true, 'select' => $categories, 'sort' => true)), array('Tags', array('search' => true, 'sort' => true)), array('Created', array('search' => true, 'sort' => true, 'date' => true)), array('Last Update', array('search' => true, 'sort' => true, 'date' => true)));
     //print $this->model->where('docFormat','picture')->get()->toJSON();
     $this->modal_sets = View::make(strtolower($this->controller_name) . '.modal')->render();
     $this->js_table_event = View::make(strtolower($this->controller_name) . '.jsevent')->render();
     return parent::getIndex();
 }
Пример #9
0
 public function getIndex()
 {
     $this->heads = array(array('Full Name', array('search' => true, 'sort' => true)), array('Role', array('search' => true, 'sort' => false, 'select' => Prefs::getRole()->RoleToSelection('_id', 'rolename'))), array('Email', array('search' => true, 'sort' => true)), array('Mobile', array('search' => true, 'sort' => true)), array('Address', array('search' => true, 'sort' => true)), array('Created', array('search' => true, 'sort' => true, 'date' => true)), array('Last Update', array('search' => true, 'sort' => true, 'date' => true)));
     $this->title = 'Users';
     $this->place_action = 'first';
     Breadcrumbs::addCrumb('Profile', URL::to(strtolower($this->controller_name)));
     //return parent::getIndex();
     $bt_edit = '<a href="' . URL::to('profile/edit/' . Auth::user()->_id) . '" class="btn btn-sm btn-primary btn-transparent"><i class="fa fa-edit"></i> Edit</a>';
     return View::make('profile.index')->with('title', Auth::user()->fullname . ' ' . $bt_edit);
 }
 /**
  * Envoie un minimail
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/10/18
  * @param string title Titre du minimail
  * @param string message Corps du minimail
  * @param integer from_id Id utilisateur de l'exp�diteur
  * @param array destin Id tableau avec les destinataires (cl� = id user)
  * @return mixed Id du message cr�� ou NULL si erreur
  */
 public function sendMinimail($title, $message, $from_id, $destin, $format)
 {
     $res = NULL;
     $DAOminimail_from = _dao("minimail|minimail_from");
     $DAOminimail_to = _dao("minimail|minimail_to");
     $newMp = _record("minimail|minimail_from");
     $newMp->title = $title;
     $newMp->message = $message;
     $newMp->format = $format;
     $newMp->date_send = date("Y-m-d H:i:s");
     $newMp->from_id = $from_id;
     $newMp->is_deleted = 0;
     $DAOminimail_from->insert($newMp);
     if ($newMp->id !== NULL) {
         //print_r($newMp);
         // On parcourt chaque destinataire
         while (list($to_id, ) = each($destin)) {
             // print_r("to_id=$to_id / to_login=$to_login");
             $newDest = _record("minimail|minimail_to");
             $newDest->id_message = $newMp->id;
             $newDest->to_id = $to_id;
             $newDest->date_read = 0;
             $newDest->is_read = 0;
             $newDest->is_replied = 0;
             $newDest->is_deleted = 0;
             $DAOminimail_to->insert($newDest);
             // ======= Alerte mail ===============
             // On vérifie que l'envoi de mails est activé, qu'un serveur SMTP est configuré, que le destinataire a coché l'option "etre prêvenu par mail" et qu'il a renseigné un mail
             if ($newDest->id2 && CopixConfig::get('|mailEnabled') == 1 && CopixConfig::get('|mailSmtpHost')) {
                 $prefs = Prefs::getPrefs($to_id);
                 if (isset($prefs['prefs']['alerte_mail_email']) && isset($prefs['minimail']['alerte_minimail']) && $prefs['prefs']['alerte_mail_email'] && $prefs['minimail']['alerte_minimail'] == 1) {
                     $userInfoFrom = Kernel::getUserInfo("ID", $from_id);
                     //print_r($userInfoFrom);
                     $to = $prefs['prefs']['alerte_mail_email'];
                     $auteur = utf8_decode($userInfoFrom['prenom'] . ' ' . $userInfoFrom['nom'] . ' (' . $userInfoFrom['login'] . ')');
                     $subject = CopixI18N::get('minimail|minimail.mail.alert.subject', array($auteur));
                     $message = str_replace('<br />', "\n", CopixI18N::get('minimail|minimail.mail.alert.body', array($auteur, CopixUrl::get('minimail||getMessage', array('id' => $newMp->id)), CopixUrl::get())));
                     $from = CopixConfig::get('default|mailFrom');
                     $fromName = CopixConfig::get('default|mailFromName');
                     $cc = $cci = '';
                     $monMail = new CopixTextEMail($to, $cc, $cci, $subject, $message);
                     $send = $monMail->send($from, $fromName);
                 }
             }
             // ======= Fin alerte mail ===============
         }
         $res = $newMp->id;
         if ($res) {
             $plugStats = CopixPluginRegistry::get("stats|stats");
             $plugStats->setParams(array('module' => 'minimail', 'action' => 'sendMinimail', 'objet_a' => $res));
         }
     }
     return $res;
 }
Пример #11
0
 public function afterSave($data)
 {
     //print_r($data);
     //exit();
     if ($data['sendOption'] == 'immediately') {
         //make queue id
         $qid = Prefs::makeQueueId();
         $qdate = new MongoDate();
         $cid = $data['_id']->toString();
         $cmp = Campaign::find($cid);
         $cmp->push(array('queueId' => $qid, 'queueInitTime' => $qdate));
         $cmp->save();
         //put into queue
         //set history
     } else {
     }
     return $data;
 }
 /**
  * Affiche la fiche détaillée d'un utilisateur (login, nom, prénom...)
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/01/04
  * @param string $type Type de personne (USER_ELE, USER_ELE...)
  * @param integer $id Id
  */
 public function _createContent(&$toReturn)
 {
     $annuaireService =& CopixClassesFactory::Create('annuaire|AnnuaireService');
     $type = $this->getParam('type') ? $this->getParam('type') : NULL;
     $id = $this->getParam('id') ? $this->getParam('id') : NULL;
     $canWrite = $canView = false;
     if ($type && $id) {
         $usr = Kernel::getUserInfo($type, $id);
         $usr['type_nom'] = Kernel::Code2Name($usr['type']);
         //Kernel::myDebug($usr);
         $droits = Kernel::getUserInfoMatrix($usr);
         $canView = $droits['voir'];
         $canWrite = $droits['communiquer'];
         if ($canView) {
             // Avatar
             $avatar = '';
             if (isset($usr['user_id'])) {
                 $avatar = Prefs::get('prefs', 'avatar', $usr['user_id']);
             }
             $usr['avatar'] = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
             $parents = $enfants = array();
             if ($type == 'USER_ELE') {
                 // Pour un élève, on cherche ses parents
                 $parents = $annuaireService->getParentsFromEleve($id);
             } elseif ($type == 'USER_RES') {
                 // Pour un parent, on cherche ses enfants
                 $enfants = $annuaireService->getEnfantsFromParent($id);
             }
         } else {
             $usr = $parents = $enfants = false;
         }
         $tpl = new CopixTpl();
         $tpl->assign('usr', $usr);
         $tpl->assign('canWrite', $canWrite);
         $tpl->assign('parents', $parents);
         $tpl->assign('enfants', $enfants);
         $toReturn = $tpl->fetch('getuserprofilzone.tpl');
     }
     return true;
 }
Пример #13
0
 public static function updateStock($data, $positive = 'available', $negative = 'deleted')
 {
     //print_r($data);
     $outlets = $data['outlets'];
     $outletNames = $data['outletNames'];
     $addQty = $data['addQty'];
     $adjustQty = $data['adjustQty'];
     unset($data['outlets']);
     unset($data['outletNames']);
     unset($data['addQty']);
     unset($data['adjustQty']);
     $productDetail = Product::find($data['id'])->toArray();
     // year and month used fro batchnumber
     $year = date('Y', time());
     $month = date('m', time());
     for ($i = 0; $i < count($outlets); $i++) {
         $su = array('outletId' => $outlets[$i], 'outletName' => $outletNames[$i], 'productId' => $data['id'], 'SKU' => $data['SKU'], 'productDetail' => $productDetail, 'status' => $positive, 'createdDate' => new MongoDate(), 'lastUpdate' => new MongoDate());
         if ($addQty[$i] > 0) {
             for ($a = 0; $a < $addQty[$i]; $a++) {
                 $su['_id'] = str_random(8);
                 $batchnumber = Prefs::GetBatchId($data['SKU'], $year, $month);
                 $su['_id'] = $data['SKU'] . '|' . $batchnumber;
                 $history = array('datetime' => new MongoDate(), 'action' => 'init', 'price' => $productDetail['priceRegular'], 'status' => $su['status'], 'outletName' => $su['outletName']);
                 $su['history'] = array($history);
                 Stockunit::insert($su);
             }
         }
         if ($adjustQty[$i] > 0) {
             $td = Stockunit::where('outletId', $outlets[$i])->where('productId', $data['id'])->where('SKU', $data['SKU'])->where('status', 'available')->orderBy('createdDate', 'asc')->take($adjustQty[$i])->get();
             foreach ($td as $d) {
                 $d->status = $negative;
                 $d->lastUpdate = new MongoDate();
                 $d->save();
                 $history = array('datetime' => new MongoDate(), 'action' => 'delete', 'price' => $d->priceRegular, 'status' => $d->status, 'outletName' => $d->outletName);
                 $d->push('history', $history);
             }
         }
     }
 }
Пример #14
0
 function execute()
 {
     if (Config::lpStoreRedis) {
         $key = get_class() . ':' . $this->typeID . ',' . $this->qty;
         $cache = json_decode($this->bpcCache->get($key), true);
         if (empty($cache) || empty($cache['manDetails']) || $cache['version'] != Db::$dbName) {
             $cache = array('version' => Db::$dbName, 'manDetails' => $this->performQuery());
             $this->bpcCache->set($key, json_encode($cache));
         }
     } else {
         $cache = array('version' => Db::$dbName, 'manDetails' => $this->performQuery());
     }
     # set price info for manufacturing materials
     foreach ($cache['manDetails'] as &$manItem) {
         try {
             $price = new Price(Emdr::get($manItem['typeID']));
             $manItem['price'] = $price->{Prefs::get('marketMat')}[0];
             $manItem['totPrice'] = $manItem['price'] * $manItem['totQty'];
         } catch (Exception $e) {
             array_push($this->noCache, $manItem['typeName']);
         }
     }
     return $cache['manDetails'];
 }
Пример #15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $logistic_id = 'CGKN00027';
     $logistic = Logistic::where('consignee_olshop_cust', '=', $logistic_id)->first();
     if (Prefs::isRunning($this->name)) {
         $l = array();
         $l['ts'] = new MongoDate();
         $l['error'] = 'process already running';
         $l['consignee_logistic_id'] = $logistic->logistic_code;
         $l['consignee_olshop_cust'] = $logistic_id;
         Threeplstatuserror::insert($l);
         die('process already running');
     }
     $orders = Shipment::where('awb', '!=', '')->where('bucket', '=', Config::get('jayon.bucket_tracker'))->where(function ($sq) {
         $sq->where('status', '!=', 'delivered')->where('status', '!=', 'undelivered')->where('status', '!=', 'canceled')->where('status', '!=', 'returned');
     })->where('logistic_type', '=', 'external')->where('consignee_olshop_cust', '=', $logistic_id)->get();
     $res = array();
     print 'count ' . count($orders->toArray());
     if ($orders && count($orders->toArray()) > 0) {
         $req = array();
         foreach ($orders as $ord) {
             //$req[] = array('order_id'=>$ord->no_sales_order.'-'.$ord->consignee_olshop_orderid,'awb'=>$ord->awb);
             $req[] = array('order_id' => $ord->consignee_olshop_orderid, 'awb' => $ord->consignee_olshop_orderid);
         }
         $client = new GuzzleClient();
         //TO DO : Send data in chunk
         $reqchunks = array_chunk($req, 100);
         foreach ($reqchunks as $rq) {
             $this->sendData($rq, $client, $logistic, $logistic_id);
         }
     } else {
         print 'Empty order list' . "\r\n";
     }
     $actor = $this->name;
     Event::fire('log.api', array('JayaStatusDaemon', 'get', $actor, 'JAYA STATUS PULL'));
 }
Пример #16
0
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('self_assign.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
$issue_id = $_REQUEST['iss_id'];
$tpl->assign('issue_id', $issue_id);
// check if issue is assigned to someone else and if so, confirm change.
$assigned_user_ids = Issue::getAssignedUserIDs($issue_id);
if (count($assigned_user_ids) > 0 && empty($_REQUEST['target'])) {
    $tpl->assign(array('prompt_override' => 1, 'assigned_users' => Issue::getAssignedUsers($issue_id)));
} else {
    $issue_details = Issue::getDetails($issue_id);
    // force assignment change
    if (@$_REQUEST['target'] == 'replace') {
        // remove current user(s) first
        Issue::deleteUserAssociations($issue_id, $usr_id);
    }
    $res = Issue::addUserAssociation($usr_id, $issue_id, $usr_id);
    $tpl->assign('self_assign_result', $res);
    Notification::subscribeUser($usr_id, $issue_id, $usr_id, Notification::getDefaultActions($issue_id, User::getEmail($usr_id), 'self_assign'));
    Workflow::handleAssignmentChange($prj_id, $issue_id, $usr_id, $issue_details, Issue::getAssignedUserIDs($issue_id), false);
}
$tpl->assign('current_user_prefs', Prefs::get($usr_id));
$tpl->displayTemplate();
Пример #17
0
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
// | GNU General Public License for more details.                         |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 51 Franklin Street, Suite 330                                          |
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../../init.php';
$tpl = new Template_Helper();
$tpl->setTemplate('reports/workload_time_period.tpl.html');
Auth::checkAuthentication(APP_COOKIE);
$usr_id = Auth::getUserID();
if (!Access::canAccessReports(Auth::getUserID())) {
    echo 'Invalid role';
    exit;
}
$prj_id = Auth::getCurrentProject();
// get timezone of current user
$user_prefs = Prefs::get($usr_id);
if (@$_GET['type'] == 'email') {
    $data = Report::getEmailWorkloadByTimePeriod(@$user_prefs['timezone']);
} else {
    $data = Report::getWorkloadByTimePeriod(@$user_prefs['timezone']);
}
$tpl->assign(array('data' => $data, 'type' => @$_GET['type'], 'user_tz' => Date_Helper::getTimezoneShortNameByUser($usr_id)));
$tpl->displayTemplate();
Пример #18
0
    <div class="span4">
		<table class="items table table-bordered table-condensed">
			<thead>
				<tr>
					<th>Статистика</th>
				</tr>
			</thead>
			<tbody>
				<tr class="odd">
					<td>
						<div class="pull-left muted">
							<b>Размер базы данных</b>
						</div>
						<div class="pull-right">
							<?php 
echo Prefs::db_size();
?>
						</div>
					</td>
				</tr>
				<tr class="odd">
					<td>
						<div class="pull-left muted">
							<b>Банов в истории</b>
						</div>
						<div class="pull-right">
							<?php 
echo $sysinfo['bancount'];
?>
						</div>
					</td>
Пример #19
0
            $email_details = Support::getEmailDetails(Email_Account::getAccountByEmail($item[0]), $item[0]);
            $tpl->assign(array('issue_summary' => $email_details['sup_subject'], 'issue_description' => $email_details['seb_body']));
            // also auto pre-fill the customer contact text fields
            if (CRM::hasCustomerIntegration($prj_id)) {
                $sender_email = Mail_Helper::getEmailAddress($email_details['sup_from']);
                try {
                    $contact = $crm->getContactByEmail($sender_email);
                    $tpl->assign('contact_details', $contact->getDetails());
                } catch (CRMException $e) {
                }
            }
        }
    }
}
$tpl->assign(array('cats' => Category::getAssocList($prj_id), 'priorities' => Priority::getAssocList($prj_id), 'severities' => Severity::getList($prj_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'releases' => Release::getAssocList($prj_id), 'custom_fields' => Custom_Field::getListByProject($prj_id, 'report_form'), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'max_attachment_bytes' => Attachment::getMaxAttachmentSize(true), 'field_display_settings' => Project::getFieldDisplaySettings($prj_id), 'groups' => Group::getAssocList($prj_id), 'products' => Product::getList(false)));
$prefs = Prefs::get($usr_id);
$tpl->assign('user_prefs', $prefs);
$tpl->assign('zones', Date_Helper::getTimezoneList());
if (Auth::getCurrentRole() == User::getRoleID('Customer')) {
    $crm = CRM::getInstance(Auth::getCurrentProject());
    $customer_contact_id = User::getCustomerContactID($usr_id);
    $contact = $crm->getContact($customer_contact_id);
    $customer_id = Auth::getCurrentCustomerID();
    $customer = $crm->getCustomer($customer_id);
    // TODOCRM: Pull contacts via ajax when user selects contract
    $tpl->assign(array('customer_id' => $customer_id, 'contact_id' => $customer_contact_id, 'customer' => $customer, 'contact' => $contact));
}
$clone_iss_id = isset($_GET['clone_iss_id']) ? (int) $_GET['clone_iss_id'] : null;
if ($clone_iss_id && Access::canCloneIssue($clone_iss_id, $usr_id)) {
    $tpl->assign(Issue::getCloneIssueTemplateVariables($clone_iss_id));
} else {
Пример #20
0
 /**
  * Method used to get the preferences set by a specific user.
  *
  * @param integer $usr_id The user ID
  * @param bool $force Set to true to force database refresh
  * @return array The preferences
  */
 public static function get($usr_id, $force = false)
 {
     static $returns;
     if (!$force && !empty($returns[$usr_id])) {
         return $returns[$usr_id];
     }
     $sql = 'SELECT
                 upr_timezone as timezone,
                 upr_week_firstday as week_firstday,
                 upr_list_refresh_rate as list_refresh_rate,
                 upr_email_refresh_rate as email_refresh_rate,
                 upr_email_signature as email_signature,
                 upr_auto_append_email_sig as auto_append_email_sig,
                 upr_auto_append_note_sig as auto_append_note_sig,
                 upr_auto_close_popup_window as close_popup_windows
             FROM
                 {{%user_preference}}
             WHERE
                 upr_usr_id=?';
     try {
         $res = DB_Helper::getInstance()->getRow($sql, array($usr_id));
     } catch (DbException $e) {
         return Prefs::getDefaults(array_keys(Project::getAssocList($usr_id, false, true)));
     }
     if ($res === null) {
         return Prefs::getDefaults(array_keys(Project::getAssocList($usr_id, false, true)));
     }
     $returns[$usr_id] = $res;
     $returns[$usr_id]['receive_assigned_email'] = array();
     $returns[$usr_id]['receive_new_issue_email'] = array();
     $returns[$usr_id]['receive_copy_of_own_action'] = array();
     // check for the refresh rate variables, and use the default values if appropriate
     if (empty($returns[$usr_id]['list_refresh_rate'])) {
         $returns[$usr_id]['list_refresh_rate'] = APP_DEFAULT_REFRESH_RATE;
     }
     if (empty($returns[$usr_id]['email_refresh_rate'])) {
         $returns[$usr_id]['email_refresh_rate'] = APP_DEFAULT_REFRESH_RATE;
     }
     // get per project preferences
     $sql = "SELECT\n                    upp_prj_id as prj_id,\n                    upp_receive_assigned_email as receive_assigned_email,\n                    upp_receive_new_issue_email as receive_new_issue_email,\n                    upp_receive_copy_of_own_action as receive_copy_of_own_action\n                FROM\n                    {{%user_project_preference}}\n                WHERE\n                    upp_usr_id = {$usr_id}";
     try {
         $res = DB_Helper::getInstance()->fetchAssoc($sql, array(), DB_FETCHMODE_ASSOC);
     } catch (DbException $e) {
         return $returns[$usr_id];
     }
     foreach ($res as $prj_id => $project_prefs) {
         $returns[$usr_id]['receive_assigned_email'][$prj_id] = $project_prefs['receive_assigned_email'];
         $returns[$usr_id]['receive_new_issue_email'][$prj_id] = $project_prefs['receive_new_issue_email'];
         $returns[$usr_id]['receive_copy_of_own_action'][$prj_id] = $project_prefs['receive_copy_of_own_action'];
     }
     return $returns[$usr_id];
 }
 /**
  * Affiche un minimail en d�tail
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/10/18
  * @param integer $id Id du minimail
  */
 public function getMessage()
 {
     $this->addJs('js/iconito/module_minimail.js');
     $MinimailService =& CopixClassesFactory::Create('minimail|MinimailService');
     // 2 DAO -> 2 assign
     $idUser = _currentUser()->getId();
     $idMessage = _request("id");
     $errors = array();
     $daoFrom = CopixDAOFactory::create("minimail_from");
     $daoTo = CopixDAOFactory::create("minimail_to");
     $message = $daoFrom->getMessage($idMessage);
     $dest = $daoTo->selectDestFromId($idMessage);
     $isRecv = $isSend = false;
     if ($message) {
         $message->prev = NULL;
         $message->next = NULL;
     }
     if ($message && $message->from_id == $idUser) {
         // Message qu'il a envoy�
         $message->type = "send";
         $prev = $daoFrom->getFromPrevMessage($message->date_send, $idUser);
         if ($prev) {
             $message->prev = $prev->id;
         }
         $next = $daoFrom->getFromNextMessage($message->date_send, $idUser);
         if ($next) {
             $message->next = $next->id;
         }
         $isSend = true;
     } else {
         // Il en est peut-�tre destinataire
         $isDest = $daoTo->selectDestFromIdAndToUser($idMessage, $idUser);
         // Test s'il est dans les destin
         if ($isDest) {
             $serv = CopixClassesFactory::create("MinimailService");
             $serv->markMinimailAsRead($dest, $idUser);
             $message->type = "recv";
             $prev = $daoTo->getToPrevMessage($message->date_send, $idUser);
             if ($prev) {
                 $message->prev = $prev->id;
             }
             $next = $daoTo->getToNextMessage($message->date_send, $idUser);
             if ($next) {
                 $message->next = $next->id;
             }
             $isRecv = true;
         } else {
             // Il tente d'afficher un message qu'il n'a pas envoy� ni re�u !
             $errors[] = CopixI18N::get('minimail.error.cantDisplay');
         }
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('minimail||')));
     } else {
         $userInfo = Kernel::getUserInfo("ID", $message->from_id);
         $message->from = $userInfo;
         $message->from_id_infos = $userInfo["prenom"] . " " . $userInfo["nom"] . " (" . $userInfo["login"] . ")";
         foreach ($dest as $j => $null) {
             //print_r($dest[$j]->to_id);
             $userInfo = Kernel::getUserInfo("ID", $dest[$j]->to_id);
             $dest[$j]->to = $userInfo;
             $dest[$j]->to_id_infos = $userInfo["prenom"] . " " . $userInfo["nom"] . " (" . $userInfo["login"] . ")";
         }
         // Avatar de l'exp�diteur
         $avatar = Prefs::get('prefs', 'avatar', $message->from_id);
         $message->avatar = $avatar ? CopixConfig::get('prefs|avatar_path') . $avatar : '';
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $message->title);
         $menu = array();
         $menu[] = array('txt' => CopixI18N::get('minimail.mess_recv'), 'url' => CopixUrl::get('minimail||getListRecv'), 'current' => $isRecv);
         $menu[] = array('txt' => CopixI18N::get('minimail.mess_send'), 'url' => CopixUrl::get('minimail||getListSend'), 'current' => $isSend);
         $menu[] = array('txt' => CopixI18N::get('minimail.mess_write'), 'url' => CopixUrl::get('minimail||getNewForm'));
         $tpl->assign('MENU', $menu);
         $message->attachment1IsImage = $MinimailService->isAttachmentImage($message->attachment1);
         $message->attachment2IsImage = $MinimailService->isAttachmentImage($message->attachment2);
         $message->attachment3IsImage = $MinimailService->isAttachmentImage($message->attachment3);
         $message->attachment1Name = $MinimailService->getAttachmentName($message->attachment1);
         $message->attachment2Name = $MinimailService->getAttachmentName($message->attachment2);
         $message->attachment3Name = $MinimailService->getAttachmentName($message->attachment3);
         //print_r($message);
         $tplListe = new CopixTpl();
         $tplListe->assign('message', $message);
         $tplListe->assign('dest', $dest);
         $result = $tplListe->fetch('getmessage.tpl');
         $tpl->assign('MAIN', $result);
         $plugStats = CopixPluginRegistry::get("stats|stats");
         $plugStats->setParams(array('objet_a' => $idMessage));
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
Пример #22
0
 public function postSynclegacy()
 {
     set_time_limit(0);
     $mymerchant = Merchant::where('group_id', 4)->get();
     $count = 0;
     foreach ($mymerchant->toArray() as $m) {
         $member = Member::where('legacyId', $m['id'])->first();
         if ($member) {
         } else {
             $member = new Member();
         }
         foreach ($m as $k => $v) {
             $member->{$k} = $v;
         }
         if (!isset($member->status)) {
             $member->status = 'inactive';
         }
         if (!isset($member->url)) {
             $member->url = '';
         }
         $member->legacyId = new MongoInt32($m['id']);
         $member->roleId = Prefs::getRoleId('Merchant');
         $member->unset('id');
         $member->save();
         $count++;
     }
     return Response::json(array('result' => 'OK', 'count' => $count));
 }
Пример #23
0
 /**
  * Returns the data used by the weekly report.
  *
  * @param string $usr_id The ID of the user this report is for.
  * @param int $prj_id The project id
  * @param string|DateTime $start The start date of this report.
  * @param string|DateTime $end The end date of this report.
  * @param array $options extra options for report:
  * - $separate_closed If closed issues should be separated from other issues.
  * - $ignore_statuses If issue status changes should be ignored in report.
  * - $separate_not_assigned_to_user Separate Issues Not Assigned to User
  * - $show_per_issue Add time spent on issue to issues
  * - $separate_no_time Separate No time spent issues
  * @return array An array of data containing all the elements of the weekly report.
  */
 public static function getWeeklyReport($usr_id, $prj_id, $start, $end, $options = array())
 {
     // figure out timezone
     $user_prefs = Prefs::get($usr_id);
     $tz = $user_prefs['timezone'];
     // if start or end is string, convert assume min and max date are specified
     if (!$start instanceof DateTime) {
         $start = Date_Helper::getDateTime($start, $tz)->setTime(0, 0, 0);
     }
     if (!$end instanceof DateTime) {
         $end = Date_Helper::getDateTime($end, $tz)->setTime(23, 59, 59);
     }
     $start_ts = Date_Helper::getSqlDateTime($start);
     $end_ts = Date_Helper::getSqlDateTime($end);
     $time_tracking = Time_Tracking::getSummaryByUser($usr_id, $prj_id, $start_ts, $end_ts);
     // replace spaces in index with _ and calculate total time
     $total_time = 0;
     foreach ($time_tracking as $category => $data) {
         unset($time_tracking[$category]);
         $time_tracking[str_replace(' ', '_', $category)] = $data;
         $total_time += $data['total_time'];
     }
     // get count of issues assigned in week of report.
     $stmt = 'SELECT
                 COUNT(*)
              FROM
                 {{%issue}},
                 {{%issue_user}},
                 {{%status}}
              WHERE
                 iss_id = isu_iss_id AND
                 iss_sta_id = sta_id AND
                 isu_usr_id = ? AND
                 iss_prj_id = ? AND
                 isu_assigned_date BETWEEN ? AND ?';
     $params = array($usr_id, Auth::getCurrentProject(), $start_ts, $end_ts);
     try {
         $newly_assigned = DB_Helper::getInstance()->getOne($stmt, $params);
     } catch (DbException $e) {
         $newly_assigned = null;
     }
     $email_count = array('associated' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, true), 'other' => Support::getSentEmailCountByUser($usr_id, $start_ts, $end_ts, false));
     $htt_exclude = array();
     if (!empty($options['ignore_statuses'])) {
         $htt_exclude[] = 'status_changed';
         $htt_exclude[] = 'status_auto_changed';
         $htt_exclude[] = 'remote_status_change';
     }
     $issue_list = History::getTouchedIssuesByUser($usr_id, $prj_id, $start_ts, $end_ts, $htt_exclude);
     $issues = array('no_time' => array(), 'not_mine' => array(), 'closed' => array(), 'other' => array());
     // organize issues into categories
     if ($issue_list) {
         if (!empty($options['show_per_issue']) || !empty($options['separate_no_time'])) {
             Time_Tracking::fillTimeSpentByIssueAndTime($issue_list, $usr_id, $start_ts, $end_ts);
         }
         foreach ($issue_list as $row) {
             if (!empty($row['iss_customer_id']) && CRM::hasCustomerIntegration($row['iss_prj_id'])) {
                 $row['customer_name'] = CRM::getCustomerName($row['iss_prj_id'], $row['iss_customer_id']);
             } else {
                 $row['customer_name'] = null;
             }
             if (!empty($options['separate_closed']) && $row['sta_is_closed'] == 1) {
                 $issues['closed'][] = $row;
             } elseif (!empty($options['separate_not_assigned_to_user']) && !Issue::isAssignedToUser($row['iss_id'], $usr_id)) {
                 $issues['not_mine'][] = $row;
             } elseif (!empty($options['separate_no_time']) && empty($row['it_spent'])) {
                 $issues['no_time'][] = $row;
             } else {
                 $issues['other'][] = $row;
             }
         }
         $sort_function = function ($a, $b) {
             return strcasecmp($a['customer_name'], $b['customer_name']);
         };
         usort($issues['closed'], $sort_function);
         usort($issues['other'], $sort_function);
     }
     return array('start' => $start_ts, 'end' => $end_ts, 'user' => User::getDetails($usr_id), 'group_name' => Group::getName(User::getGroupID($usr_id)), 'issues' => $issues, 'status_counts' => History::getTouchedIssueCountByStatus($usr_id, $prj_id, $start_ts, $end_ts), 'new_assigned_count' => $newly_assigned, 'time_tracking' => $time_tracking, 'email_count' => $email_count, 'phone_count' => Phone_Support::getCountByUser($usr_id, $start_ts, $end_ts), 'note_count' => Note::getCountByUser($usr_id, $start_ts, $end_ts), 'total_time' => Misc::getFormattedTime($total_time, false));
 }
Пример #24
0
 public function order_save($indata, $api_key, $transaction_id)
 {
     date_default_timezone_set('Asia/Jakarta');
     $args = '';
     //$api_key = $this->get('key');
     //$transaction_id = $this->get('trx');
     if (is_null($api_key)) {
         $result = json_encode(array('status' => 'ERR:NOKEY', 'timestamp' => now()));
         return $result;
     } else {
         $app = \Prefs::get_key_info(trim($api_key));
         if ($app == false) {
             $result = json_encode(array('status' => 'ERR:INVALIDKEY', 'timestamp' => now()));
             return $result;
         } else {
             //$in = $this->input->post('transaction_detail');
             //$in = file_get_contents('php://input');
             $in = $indata;
             //print $in;
             $buyer_id = 1;
             $args = 'p=' . $in;
             $in = json_decode($in);
             //print "order input to save: \r\n";
             //print_r($in);
             $is_new = false;
             $in->phone = isset($in->phone) && $in->phone != '' ? \Prefs::normalphone($in->phone) : '';
             $in->mobile1 = isset($in->mobile1) && $in->mobile1 != '' ? \Prefs::normalphone($in->mobile1) : '';
             $in->mobile2 = isset($in->mobile2) && $in->mobile2 != '' ? \Prefs::normalphone($in->mobile2) : '';
             if (isset($in->buyer_id) && $in->buyer_id != '' && $in->buyer_id > 1) {
                 $buyer_id = $in->buyer_id;
                 $is_new = false;
             } else {
                 if ($in->email == '' || $in->email == '-' || !isset($in->email) || $in->email == 'noemail') {
                     $in->email = 'noemail';
                     $is_new = true;
                     if (trim($in->phone . $in->mobile1 . $in->mobile2) != '') {
                         if ($buyer = \Prefs::check_phone($in->phone, $in->mobile1, $in->mobile2)) {
                             $buyer_id = $buyer['id'];
                             $is_new = false;
                         }
                     }
                 } else {
                     if ($buyer = \Prefs::check_email($in->email)) {
                         $buyer_id = $buyer['id'];
                         $is_new = false;
                     } else {
                         if ($buyer = \Prefs::check_phone($in->phone, $in->mobile1, $in->mobile2)) {
                             $buyer_id = $buyer['id'];
                             $is_new = false;
                         }
                     }
                 }
             }
             if (isset($in->merchant_trans_id) && $in->merchant_trans_id != "") {
                 $transaction_id = $in->merchant_trans_id;
             }
             if ($is_new) {
                 $random_string = str_random(5);
                 $buyer_username = substr(strtolower(str_replace(' ', '', $in->buyer_name)), 0, 6) . $random_string;
                 $dataset['username'] = $buyer_username;
                 $dataset['email'] = $in->email;
                 $dataset['phone'] = $in->phone;
                 $dataset['mobile1'] = $in->mobile1;
                 $dataset['mobile2'] = $in->mobile2;
                 $dataset['fullname'] = $in->buyer_name;
                 $password = str_random(8);
                 $dataset['password'] = $password;
                 $dataset['created'] = date('Y-m-d H:i:s', time());
                 /*
                 $dataset['province'] =
                 $dataset['mobile']
                 */
                 $dataset['street'] = $in->shipping_address;
                 $dataset['district'] = $in->buyerdeliveryzone;
                 $dataset['city'] = $in->buyerdeliverycity;
                 $dataset['country'] = 'Indonesia';
                 $dataset['zip'] = isset($in->zip) ? $in->zip : '';
                 //$buyer_id = $this->register_buyer($dataset);
                 $is_new = true;
             }
             $order['created'] = date('Y-m-d H:i:s', time());
             $order['ordertime'] = date('Y-m-d H:i:s', time());
             $order['application_id'] = $app->id;
             $order['application_key'] = $app->key;
             $order['buyer_id'] = $buyer_id;
             $order['merchant_id'] = $app->merchant_id;
             $order['merchant_trans_id'] = trim($transaction_id);
             $order['buyer_name'] = $in->buyer_name;
             $order['recipient_name'] = $in->recipient_name;
             $order['email'] = $in->email;
             $order['directions'] = $in->directions;
             //$order['dir_lat'] = $in->dir_lat;
             //$order['dir_lon'] = $in->dir_lon;
             $order['buyerdeliverytime'] = $in->buyerdeliverytime;
             $order['buyerdeliveryslot'] = $in->buyerdeliveryslot;
             $order['buyerdeliveryzone'] = $in->buyerdeliveryzone;
             $order['buyerdeliverycity'] = is_null($in->buyerdeliverycity) || $in->buyerdeliverycity == '' ? 'Jakarta' : $in->buyerdeliverycity;
             $order['currency'] = $in->currency;
             $order['total_price'] = isset($in->total_price) ? $in->total_price : 0;
             $order['total_discount'] = isset($in->total_discount) ? $in->total_discount : 0;
             $order['total_tax'] = isset($in->total_tax) ? $in->total_tax : 0;
             if (in_array(strtoupper(trim($in->delivery_type)), array('COD', 'CCOD', 'PS', 'DO', 'DELIVERY ONLY'))) {
                 $in->delivery_type = 'COD';
             }
             $order['delivery_type'] = $in->delivery_type;
             if ($in->delivery_type == 'DO' || $in->delivery_type == 'Delivery Only') {
                 $order['cod_cost'] = 0;
             } else {
                 $order['cod_cost'] = \Prefs::get_cod_tariff($order['total_price'], $app->id);
             }
             $order['box_count'] = isset($in->box_count) ? $in->box_count : 1;
             $order['pending_count'] = isset($in->pending_count) ? $in->pending_count : 0;
             $order['delivery_note'] = isset($in->delivery_note) ? $in->delivery_note : '';
             $order['shipping_address'] = $in->shipping_address;
             $order['shipping_zip'] = $in->shipping_zip;
             $order['phone'] = $in->phone;
             $order['mobile1'] = $in->mobile1;
             $order['mobile2'] = $in->mobile2;
             $order['status'] = $in->status;
             $order['width'] = $in->width;
             $order['height'] = $in->height;
             $order['length'] = $in->length;
             $order['weight'] = isset($in->weight) ? $in->weight : 0;
             $order['actual_weight'] = isset($in->actual_weight) ? $in->actual_weight : 0;
             $order['delivery_cost'] = $order['weight'];
             $order['cod_bearer'] = isset($in->cod_bearer) ? $in->cod_bearer : 'merchant';
             $order['delivery_bearer'] = isset($in->delivery_bearer) ? $in->delivery_bearer : 'merchant';
             $order['cod_method'] = isset($in->cod_method) ? $in->cod_method : 'cash';
             $order['ccod_method'] = isset($in->ccod_method) ? $in->ccod_method : 'full';
             $order['fulfillment_code'] = isset($in->fulfillment_code) ? $in->fulfillment_code : '';
             // check out who is bearing the cost
             if ($order['delivery_type'] == 'COD' || $order['delivery_type'] == 'CCOD') {
                 if ($order['delivery_bearer'] == 'merchant') {
                     $dcost = 0;
                 } else {
                     $dcost = $order['delivery_cost'];
                 }
                 if ($order['cod_bearer'] == 'merchant') {
                     $codcost = 0;
                 } else {
                     $codcost = $order['cod_cost'];
                 }
                 $order['chargeable_amount'] = $order['total_price'] + $dcost + $codcost;
             } else {
                 if ($order['delivery_bearer'] == 'merchant') {
                     $dcost = 0;
                 } else {
                     $dcost = $order['delivery_cost'];
                 }
                 $order['chargeable_amount'] = $dcost;
             }
             if (isset($in->show_shop)) {
                 $order['show_shop'] = $in->show_shop;
             }
             if (isset($in->show_merchant)) {
                 $order['show_merchant'] = $in->show_merchant;
             }
             $order['is_api'] = 1;
             $ship = new \Shipment();
             foreach ($order as $k => $v) {
                 $ship->{$k} = $v;
             }
             $ship->save();
             $sequence = $ship->id;
             if (isset($in->delivery_id)) {
                 if (is_null($in->delivery_id) || $in->delivery_id == '') {
                     $delivery_id = \Prefs::get_delivery_id($sequence, $app->merchant_id);
                 } else {
                     $delivery_id = \Prefs::get_delivery_id($sequence, $app->merchant_id, $in->delivery_id);
                 }
             } else {
                 $delivery_id = \Prefs::get_delivery_id($sequence, $app->merchant_id);
             }
             $ship->delivery_id = $delivery_id;
             //print_r($ship);
             $ship->save();
             //die();
             if (isset($in->box_count)) {
                 $box_count = $in->box_count;
             } else {
                 $box_count = 1;
             }
             \Prefs::save_box($delivery_id, trim($transaction_id), $order['fulfillment_code'], $box_count);
             $nedata['fullname'] = $in->buyer_name;
             $nedata['merchant_trx_id'] = trim($transaction_id);
             $nedata['delivery_id'] = $delivery_id;
             $nedata['merchantname'] = $app->application_name;
             $nedata['app'] = $app;
             $order['delivery_id'] = $delivery_id;
             $buyer_id = \Prefs::save_buyer($order);
             /*
             $this->db->where('id',$sequence)->update($this->config->item('incoming_delivery_table'),array('delivery_id'=>$delivery_id));
             */
             /*
                 $this->table_tpl = array(
                     'table_open' => '<table border="0" cellpadding="4" cellspacing="0" class="dataTable">'
                 );
                 $this->table->set_template($this->table_tpl);
             
             
                 $this->table->set_heading(
                     'No.',
                     'Description',
                     'Quantity',
                     'Total'
                     ); // Setting headings for the table
             */
             $d = 0;
             $gt = 0;
             if ($in->trx_detail) {
                 $seq = 0;
                 foreach ($in->trx_detail as $it) {
                     $item = new \Deliverydetail();
                     $item->ordertime = $order['ordertime'];
                     $item->delivery_id = $delivery_id;
                     $item->unit_sequence = $seq++;
                     $item->unit_description = $it->unit_description;
                     $item->unit_price = $it->unit_price;
                     $item->unit_quantity = $it->unit_quantity;
                     $item->unit_total = $it->unit_total;
                     $item->unit_discount = $it->unit_discount;
                     $item->save();
                     /*
                     $this->table->add_row(
                         (int)$item['unit_sequence'] + 1,
                         $item['unit_description'],
                         $item['unit_quantity'],
                         $item['unit_total']
                     );
                     
                     $u_total = str_replace(array(',','.'), '', $item['unit_total']);
                     $u_discount = str_replace(array(',','.'), '', $item['unit_discount']);
                     $gt += (int)$u_total;
                     $d += (int)$u_discount;
                     */
                 }
                 $total = isset($in->total_price) && $in->total_price > 0 ? $in->total_price : 0;
                 $total = str_replace(array(',', '.'), '', $total);
                 $total = (int) $total;
                 $gt = $total < $gt ? $gt : $total;
                 $disc = isset($in->total_discount) ? $in->total_discount : 0;
                 $tax = isset($in->total_tax) ? $in->total_tax : 0;
                 $cod = isset($in->cod_cost) ? $in->cod_cost : 'Paid by merchant';
                 $disc = str_replace(array(',', '.'), '', $disc);
                 $tax = str_replace(array(',', '.'), '', $tax);
                 $cod = str_replace(array(',', '.'), '', $cod);
                 $disc = (int) $disc;
                 $tax = (int) $tax;
                 $cod = (int) $cod;
                 $chg = $gt - $disc + $tax + $cod;
                 /*
                 $this->table->add_row(
                     '',
                     '',
                     'Total Price',
                     number_format($gt,2,',','.')
                 );
                 
                 $this->table->add_row(
                     '',
                     '',
                     'Total Discount',
                     number_format($disc,2,',','.')
                 );
                 
                 $this->table->add_row(
                     '',
                     '',
                     'Total Tax',
                     number_format($tax,2,',','.')
                 );
                 
                 
                 if($cod == 0){
                     $this->table->add_row(
                         '',
                         '',
                         'COD Charges',
                         'Paid by Merchant'
                     );
                 }else{
                     $this->table->add_row(
                         '',
                         '',
                         'COD Charges',
                         number_format($cod,2,',','.')
                     );
                 }
                 
                 
                 $this->table->add_row(
                     '',
                     '',
                     'Total Charges',
                     number_format($chg,2,',','.')
                 );
                 
                 $nedata['detail'] = $this->table;
                 
                 
                 $result = json_encode(array('status'=>'OK:ORDERPOSTED','timestamp'=>now(),'delivery_id'=>$delivery_id,'buyer_id'=>$buyer_id));
                 */
                 //return $ship->toArray();
             } else {
                 //$nedata['detail'] = false;
                 //$result = json_encode(array('status'=>'OK:ORDERPOSTEDNODETAIL','timestamp'=>now(),'delivery_id'=>$delivery_id));
                 //return $order;
             }
             return $ship->toArray();
             //print_r($app);
             /*
             
                             if($app->notify_on_new_order == 1){
                                 send_notification('New Delivery Order - Jayon Express COD Service',$in->email,$app->cc_to,$app->reply_to,'order_submit',$nedata,null);
                             }
             
                             if($is_new == true){
                                 $edata['fullname'] = $dataset['fullname'];
                                 $edata['username'] = $buyer_username;
                                 $edata['password'] = $password;
                                 if($app->notify_on_new_member == 1 && $in->email != 'noemail'){
                                     send_notification('New Member Registration - Jayon Express COD Service',$in->email,null,null,'new_member',$edata,null);
                                 }
             
                             }*/
         }
     }
     //$this->log_access($api_key, __METHOD__ ,$result,$args);
 }
Пример #25
0
    if (!@empty($HTTP_POST_VARS['new_status'])) {
        $res = Issue::setStatus($issue_id, $HTTP_POST_VARS['new_status']);
        if ($res != -1) {
            $new_status = Status::getStatusTitle($HTTP_POST_VARS['new_status']);
            History::add($issue_id, $usr_id, History::getTypeID('status_changed'), "Status changed to '{$new_status}' by " . User::getFullName($usr_id));
        }
    }
    $res = Note::insert($usr_id, $issue_id);
    $tpl->assign("post_result", $res);
    // enter the time tracking entry about this phone support entry
    if (!empty($HTTP_POST_VARS['time_spent'])) {
        $HTTP_POST_VARS['issue_id'] = $issue_id;
        $HTTP_POST_VARS['category'] = $HTTP_POST_VARS['time_category'];
        $HTTP_POST_VARS['summary'] = 'Time entry inserted when sending an internal note.';
        Time_Tracking::insertEntry();
    }
} elseif (@$HTTP_GET_VARS["cat"] == "reply") {
    if (!@empty($HTTP_GET_VARS["id"])) {
        $note = Note::getDetails($HTTP_GET_VARS["id"]);
        $date = Misc::formatReplyDate($note["timestamp"]);
        $header = "\n\n\nOn {$date}, " . $note["not_from"] . " wrote:\n>\n";
        $note["not_body"] = $header . Misc::formatReply($note["not_note"]);
        $tpl->bulkAssign(array("note" => $note, "parent_note_id" => $HTTP_GET_VARS["id"]));
        $reply_subject = Mail_API::removeExcessRe($note['not_title']);
    }
}
if (empty($reply_subject)) {
    $reply_subject = 'Re: ' . $details['iss_summary'];
}
$tpl->assign(array('from' => User::getFromHeader($usr_id), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'current_user_prefs' => Prefs::get($usr_id), 'subscribers' => Notification::getSubscribers($issue_id, false, User::getRoleID("Standard User")), 'statuses' => Status::getAssocStatusList($prj_id, false), 'current_issue_status' => Issue::getStatusID($issue_id), 'time_categories' => Time_Tracking::getAssocCategories(), 'note_category_id' => Time_Tracking::getCategoryID('Note Discussion'), 'reply_subject' => $reply_subject));
$tpl->displayTemplate();
Пример #26
0
 protected function afterValidate()
 {
     if ($this->scenario == 'buy') {
         return true;
     }
     if (!$this->access) {
         $this->addError('access', 'Выберите флаги доступа');
     }
     if ($this->isNewRecord && $this->flags === 'a' && !$this->password) {
         $this->addError('password', 'Для админки по нику нужно обязательно указывать пароль');
     }
     if ($this->flags === 'd' && !filter_var($this->steamid, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4))) {
         $this->addError('steamid', 'Неверно введен IP');
     }
     if ($this->flags === 'c' && !Prefs::validate_value($this->steamid, 'steamid')) {
         $this->addError('steamid', 'Неверно введен SteamID');
     }
     if ($this->password && !preg_match('#^([a-z0-9]+)$#i', $this->password)) {
         $this->addError('password', 'Пароль может содержать только буквы латинского алфавита и цифры');
     }
     if (!$this->isNewRecord && $this->days < $this->change && $this->addtake === '1') {
         $this->addError('', 'Ошибка! Нельзя забрать дней больше, чем у него уже есть');
     }
     if (empty($this->servers)) {
         $this->addError('servers', 'Выберите хотябы один сервер');
     }
     if ($this->hasErrors()) {
         return $this->getErrors();
     }
     return parent::afterValidate();
 }
Пример #27
0
 /**
  * Вывод данных о бане в модальке
  */
 public function actionBandetail()
 {
     if (is_numeric($_POST['bid'])) {
         $model = Bans::model()->with('admin')->findByPk($_POST['bid']);
         if ($model === null) {
             Yii::app()->end('alert("Ошибка!")');
         }
         $js = "\$('#bandetail-nick').html('" . CHtml::encode($model->player_nick) . "');";
         $js .= "\$('#bandetail-steam').html('" . $model->player_id . "');";
         //$js .= "$('#bandetail-steamcommynity').html('" . Prefs::steam_convert($model->player_id, true) . "');";
         $js .= "\$('#bandetail-ip').html('" . (Webadmins::checkAccess('ip_view') ? $model->player_ip : 'Cкрыт') . "');";
         //$js .= "$('#bandetail-type').html('" . Prefs::getBanType($model->ban_type) . "');";
         $js .= "\$('#bandetail-datetime').html('" . date('d.m.y - H:i:s', $model->ban_created) . "');";
         $js .= "\$('#bandetail-expired').html('" . ($model->ban_length == '-1' ? 'Разбанен' : Prefs::date2word($model->ban_length) . ($model->expired == 1 ? ' (истек)' : '')) . "');";
         $js .= "\$('#bandetail-map').html('" . $model->map_name . "');";
         $js .= "\$('#bandetail-reason').html('" . CHtml::encode($model->ban_reason) . "');";
         $js .= "\$('#bandetail-admin').html('" . CHtml::encode($model->admin_nick) . "');";
         $js .= "\$('#bandetail-server').html('" . CHtml::encode($model->server_name) . "');";
         //$js .= "$('#bandetail-kicks').html('" . $model->ban_kicks . "');";
         $js .= "\$('#loading').hide();";
         $js .= "\$('#viewban').attr({'href': '" . Yii::app()->urlManager->createUrl('/bans/view', array('id' => $_POST['bid'])) . "'});";
         $js .= "\$('#BanDetail').modal('show');";
         echo $js;
     }
     Yii::app()->end();
 }
Пример #28
0
// build list of abbreviation => Timezone
// we take first timezone and hope it's correct
$timezones = array();
foreach (DateTimeZone::listAbbreviations() as $abbrevation => $list) {
    // take first timezone
    $timezone = current($list);
    $timezones[strtoupper($abbrevation)] = $timezone['timezone_id'];
}
/** @var DbInterface $db */
$res = $db->getAll('select upr_usr_id, upr_timezone from {{%user_preference}}');
foreach ($res as $row) {
    $usr_id = $row['upr_usr_id'];
    $tz = $row['upr_timezone'];
    // skip UTC
    if (in_array($tz, array('UTC', 'GMT'))) {
        continue;
    }
    if (!$tz) {
        // if empty tz, set default from system
        $new_tz = APP_DEFAULT_TIMEZONE;
    } elseif (isset($timezones[$tz])) {
        $new_tz = $timezones[$tz];
    } else {
        // no mapping, sorry
        continue;
    }
    $prefs = Prefs::get($usr_id);
    $prefs['timezone'] = $new_tz;
    echo "Updating user #{$usr_id} timezone: {$tz} => {$prefs['timezone']}\n";
    Prefs::set($usr_id, $prefs);
}
Пример #29
0
 public function colorizetype($data)
 {
     return Prefs::colorizetype($data['delivery_type']);
 }
Пример #30
0
 /**
  * Детали админа.
  */
 public function actionView($id = NULL)
 {
     if (!Yii::app()->request->isAjaxRequest && $id !== NULL) {
         // Проверка прав
         if (!Webadmins::checkAccess('amxadmins_edit')) {
             throw new CHttpException(403, "У Вас недостаточно прав");
         }
         $model = $this->loadmodel($id);
         $this->render('view', array('model' => $model));
         Yii::app()->end();
     }
     $model = Amxadmins::model()->with('servers')->findByPk($_POST['aid']);
     if ($model === null) {
         Yii::app()->end("alert('Ошибка!')");
     }
     $steam = '';
     // Если стимайди админа проходит проверку на валидность, получаем инфу об админе с вальве
     if (Prefs::validate_value($model->steamid)) {
         if ($url = @file_get_contents(Prefs::steam_convert($model->steamid, false, true))) {
             $xmlres = simplexml_load_string($url);
             $steam = CHtml::image($xmlres->avatarIcon) . " " . CHtml::link($xmlres->steamID, "http://steamcommunity.com/profiles/" . $xmlres->steamID64, array("target" => "_blank", "rel" => "tooltip", "title" => "Просмотреть профиль"));
         }
     }
     $servers = '';
     // Если есть сервера у админа, выводим сервера
     if ($model->servers) {
         foreach ($model->servers as $server) {
             if (!$server->hostname) {
                 continue;
             }
             $servers .= CHtml::link($server->hostname, Yii::app()->createUrl('/serverinfo/view', array('id' => intval($server->id))), array('target' => '_blank')) . "<br>";
         }
     }
     // Формируем таблицу с инфой об админе
     $info = "<table class=\"table table-bordered\">";
     $info .= "<tr>";
     $info .= "<td><b>Ник</b></td>";
     $info .= "<td>" . CHtml::encode($model->nickname) . "</td>";
     $info .= "</tr><tr>";
     $info .= "<td><b>Контакты</b></td>";
     $info .= "<td>" . ($model->icq ? CHtml::image("//icq-rus.com/icq/3/" . $model->icq . ".gif") . " " . $model->icq : 'Не задан') . "</td>";
     $info .= "</tr><tr>";
     $info .= "<td><b>Доступ</b></td>";
     $info .= "<td>" . $model->access . "</td>";
     $info .= "</tr><tr>";
     $info .= "<td><b>Добавлен</b></td>";
     $info .= "<td>" . date("d.m.Y - H:i:s", $model->created) . "</td>";
     $info .= "</tr><tr>";
     $info .= "<td><b>Истекает</b></td>";
     $info .= "<td>" . ($model->expired != 0 ? date("d.m.Y - H:i:s", $model->expired) : "Никогда") . "</td>";
     $info .= "</tr>";
     $info .= "</table>";
     $js = "\$('#adminInfo').html('" . $info . "');";
     $js .= "\$('#adminSteam').html('" . ($steam ? $steam : '<i>Информация отсутствует</i>') . "');";
     $js .= "\$('#adminServers').html('" . ($model->servers ? $servers : '<i>Информация отсутствует</i>') . "');";
     $js .= "\$('#loading').hide();";
     $js .= "\$('#adminDetail').modal('show');";
     // Выводим инфу
     Yii::app()->end($js);
 }