public function configure() { $this->disableLocalCSRFProtection(); /*---------------------------------- WIDGETS CONFIGURATION ----------------------------------*/ foreach ($this->getOption('users', array()) as $user_id) { $this->widgetSchema['computer_id_' . $user_id] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Computer'), 'add_empty' => false)); $this->validatorSchema['computer_id_' . $user_id] = new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Computer'))); $this->setDefaults(array('computer_id_' . $user_id => ParametersConfiguration::getDefault('default_computer'))); } $this->widgetSchema['unitary_price'] = new sfWidgetFormInputText(); $act_price = Doctrine::getTable('ActPrice')->findOneByActIdAndActPublicCategoryId($this->getObject()->getImputation()->getActId(), $this->getOption('public_category')); if ($act_price['value'] == -1) { $this->widgetSchema->setDefault('unitary_price', 0); } else { $this->widgetSchema->setDefault('unitary_price', $act_price['value']); } /*---------------------------------- VALIDATORS CONFIGURATION ----------------------------------*/ $this->validatorSchema['imputation_id']->addOption('required', false); $this->validatorSchema['computer_id']->setOption('required', true); $this->validatorSchema['unitary_price'] = new sfValidatorNumber(); /*-------------------------------------------- LABELS ------------------------------------------*/ $this->widgetSchema->setLabel('computer_id', 'Computer'); /*--------------------------------------- FORMS EMBEDDING --------------------------------------*/ /*Embed a imputation form:*/ $subFormImputation = new ImputationForm($this->getObject()->getImputation(), array_merge($this->getOptions(), array('imputation_type' => ImputationDefaultValues::UNITARY_SERVICE_TYPE))); $this->embedForm('imputation', $subFormImputation); }
/** * * @param unknown_type $user_id * @param unknown_type $moderator_id */ public function preConfigure($user_id, $moderator_id, $act_id, $act_public_category_id = null) { ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); //Get the user: $user = Doctrine::getTable('User')->findOneById($user_id); //Get the moderator: $moderator = Doctrine::getTable('Moderator')->findOneById($moderator_id); //Get the act: //Get the moderator: $act = Doctrine::getTable('Act')->findOneById($act_id); //Set the user for the object ImputationAccountTransaction $this->getImputation()->setUser($user); //If the parameter "follow moderator actions" have been checked: set the moderator for the object ImputationAccountTransaction if (ParametersConfiguration::getDefault('default_follow_moderator')) { $this->getImputation()->setModerator($moderator); } else { //Otherwise, set it to null: $this->getImputation()->setModeratorId(null); } //Set the act $this->getImputation()->setAct($act); //Set the date (today by default): $this->getImputation()->setDate(date('m/d/Y H:i')); //Set the room, building, method of payment and unity id: $this->getImputation()->setRoomId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_ROOM, ImputationDefaultValues::PURCHASE_TYPE)); $this->getImputation()->setBuildingId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_BUILDING, ImputationDefaultValues::PURCHASE_TYPE)); $this->getImputation()->setMethodOfPaymentId(ParametersConfiguration::getDefault('default_method_of_payment')); $this->getImputation()->setUnityId(ParametersConfiguration::getDefault('default_currency')); //Set the imputation type to 2: $this->getImputation()->setImputationType(ImputationDefaultValues::PURCHASE_TYPE); }
public function executeIndex(sfWebRequest $request) { $this->moderators = Doctrine::getTable('Moderator')->createQuery('a')->orderBy('a.surname')->execute(); ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $this->defaultLength = ParametersConfiguration::getDefault('default_num_to_display'); $this->userCulture = $this->getUser()->getCulture(); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne(); sfContext::getInstance()->getUser()->setAttribute('relativeUrlRoot', $request->getRelativeUrlRoot()); if ($request->isMethod(sfRequest::POST)) { /*$context=sfContext::getInstance();*/ $login = $this->getRequestParameter('login'); $password = $this->getRequestParameter('password'); $usersAuth = new usersAuth(); $checked = $usersAuth->verifyAuth($login, $password); //if the authentification is done if ($checked == 1 || $checked == 2) { ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $loginDisplay = ParametersConfiguration::getDefault('default_follow_moderator'); /*According to the 'default_follow_moderator' parameter, the login will appear in logs or not*/ if ($loginDisplay == 1) { $this->getContext()->get('Kernel')->addLog("info", "Authentification success for the login \"" . $login . "\"."); } else { $this->getContext()->get('Kernel')->addLog("info", "Authentification success."); } //Get the preferred culture of the user, based on those which are installed: $culture = ParametersConfiguration::getDefault('default_language'); $this->getUser()->setCulture($culture); $request->setParameter('sf_culture', $culture); $this->redirect('@localized_homepage'); } else { if ($checked === 0) { // this delay complicates a brute force attack sleep(1); $this->getUser()->setFlash('error', 'Login or password incorrect. Please try again.', true); $this->getContext()->get('Kernel')->addLog("error", "Authentification denied for the login \"" . $login . "\"."); } else { if ($checked === -2) { $this->getUser()->setFlash('error', 'Login and password are correct but your account is locked.', true); $this->getContext()->get('Kernel')->addLog("error", "Authentification denied for the login \"" . $login . "\". Account is locked."); } else { //The error message is copied in the error log $this->getContext()->get('Kernel')->addLog("error", "Connection to the database failed:\"" . $checked . "\"."); $this->getUser()->setFlash('error', 'Impossible authentification. Check the connection to the database.', true); } } } } else { $this->login = null; $this->password = null; } }
/** * * @param integer $user_id * @param integer $moderator_id * @param integer $act_id * @param integer $act_public_category_id */ public function preConfigure($user_id, $moderator_id, $act_id, $act_public_category_id = null) { ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); //Get the user: $user = Doctrine::getTable('User')->findOneById($user_id); //Get the moderator: $moderator = Doctrine::getTable('Moderator')->findOneById($moderator_id); //Get the act: //Get the moderator: $act = Doctrine::getTable('Act')->findOneById($act_id); //Set the user $this->getImputation()->setUser($user); //If the parameter "follow moderator actions" have been checked: set the moderator for the object ImputationAccountTransaction if (ParametersConfiguration::getDefault('default_follow_moderator')) { $this->getImputation()->setModerator($moderator); } else { //Otherwise, set it to null: $this->getImputation()->setModeratorId(null); } //Set the act $this->getImputation()->setAct($act); //Set the imputation 'total' based on the act_price: $act_price = Doctrine::getTable('ActPrice')->findOneByActIdAndActPublicCategoryId($act_id, $act_public_category_id); if ($act_price['value'] == -1) { $this->getImputation()->setTotal(0); } else { $this->getImputation()->setTotal($act_price['value']); } //Set the 'number of unities' by default to 1: $this->setNumberOfUnities(1); //Set the date (today by default): $this->getImputation()->setDate(date('m/d/Y H:i')); //Set the end_time (current hour by default): $this->setEndTime(date('H:i')); //Set the beginning time: $this->setBeginningTimeConf($act['duration']); //Set the room, building, computer, method of payment and unity id: $this->getImputation()->setRoomId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_ROOM, ImputationDefaultValues::UNITARY_SERVICE_TYPE)); $this->getImputation()->setBuildingId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_BUILDING, ImputationDefaultValues::UNITARY_SERVICE_TYPE)); $this->setComputerId(ParametersConfiguration::getDefault('default_computer')); $this->getImputation()->setMethodOfPaymentId(ParametersConfiguration::getDefault('default_method_of_payment')); $this->getImputation()->setUnityId(ParametersConfiguration::getDefault('default_currency')); //Set the imputation type to 2: $this->getImputation()->setImputationType(ImputationDefaultValues::UNITARY_SERVICE_TYPE); }
/** * * @param integer $user_id * @param integer $moderator_id * @param integer $act_id * @param integer $act_public_category_id */ public function preConfigure($user_id, $moderator_id, $act_id, $act_public_category_id = null) { ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); //Get the user: $user = Doctrine::getTable('User')->findOneById($user_id); //Get the moderator: $moderator = Doctrine::getTable('Moderator')->findOneById($moderator_id); //Get the act: //Get the moderator: $act = Doctrine::getTable('Act')->findOneById($act_id); //Set the user $this->getImputation()->setUser($user); //If the parameter "follow moderator actions" have been checked: set the moderator for the object ImputationAccountTransaction if (ParametersConfiguration::getDefault('default_follow_moderator')) { $this->getImputation()->setModerator($moderator); } else { //Otherwise, set it to null: $this->getImputation()->setModeratorId(null); } //Set the act $this->getImputation()->setAct($act); //Set the default initial value based on the quantity of the act: $this->setInitialValue($this->getImputation()->getAct()->getQuantity()); //Set the imputation 'total' based on the act_price: $act_price = Doctrine::getTable('ActPrice')->findOneByActIdAndActPublicCategoryId($act_id, $act_public_category_id); if ($act_price['value'] == -1) { if ($this->getImputation()->getAct()->getMonetaryAccount()) { $this->getImputation()->setTotal($this->getImputation()->getAct()->getQuantity()); } else { $this->getImputation()->setTotal(0); } } else { $this->getImputation()->setTotal($act_price['value']); } //Set the date (today by default): $this->getImputation()->setDate(date('m/d/Y H:i')); //Set the room, building, method of payment and unity id: $this->getImputation()->setRoomId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_ROOM, ImputationDefaultValues::COUNTABLE_SERVICE_TYPE)); $this->getImputation()->setBuildingId(ImputationDefaultValues::getDefaultValueByType(ImputationDefaultValues::DEFAULT_BUILDING, ImputationDefaultValues::COUNTABLE_SERVICE_TYPE)); $this->getImputation()->setMethodOfPaymentId(ParametersConfiguration::getDefault('default_method_of_payment')); $this->getImputation()->setUnityId($act->getUnityId()); //Set the imputation type to 3: $this->getImputation()->setImputationType(ImputationDefaultValues::COUNTABLE_SERVICE_TYPE); }
/** * Processes the deletion of a computer. * @param sfWebRequest $request */ public function executeDeleteComputer(sfWebRequest $request) { ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $defaultComputer = ParametersConfiguration::getDefault('default_computer'); /*If this computer was the default computer, we set the parameter 'default_computer' to zero.*/ if ($defaultComputer == $request->getParameter('id')) { ParametersConfiguration::setDefault('default_computer', 0); } Doctrine_Query::create()->delete('Computer c')->where('c.id = ?', $request->getParameter('id'))->execute(); $this->getUser()->setFlash('notice', 'The computer has been deleted.'); $this->redirect('struct/index#computers'); }
public function executeAjaxImputationInfo(sfWebRequest $request) { $accountTransaction = null; $purchase = null; $countableService = null; $unitaryService = null; $subscription = null; $computer = null; $imputationId = $request->getParameter('id'); $imputation = Doctrine::getTable('Imputation')->findOneById($imputationId); switch ($imputation->getImputationType()) { case ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE: $accountTransaction = Doctrine::getTable('ImputationAccountTransaction')->findOneByImputationId($imputationId); $imputationType = "Account transaction"; break; case ImputationDefaultValues::PURCHASE_TYPE: $purchase = Doctrine::getTable('ImputationPurchase')->findOneByImputationId($imputationId); $imputationType = "Purchase"; break; case ImputationDefaultValues::COUNTABLE_SERVICE_TYPE: $countableService = Doctrine::getTable('ImputationCountableService')->findOneByImputationId($imputationId); $imputationType = "Countable service"; break; case ImputationDefaultValues::UNITARY_SERVICE_TYPE: $unitaryService = Doctrine::getTable('ImputationUnitaryService')->findOneByImputationId($imputationId); $imputationType = "Unitary service"; $computer = Doctrine::getTable('Computer')->findOneById($unitaryService['computer_id'])->getName(); break; case ImputationDefaultValues::SUBSCRIPTION_TYPE: $subscription = Doctrine::getTable('ImputationSubscription')->findOneByImputationId($imputationId); $imputationType = "Subscription"; break; } ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $this->defaultCurrency = Doctrine::getTable('Unity')->findOneById(ParametersConfiguration::getDefault('default_currency'))->getShortenedDesignation(); $this->accountTransaction = $accountTransaction; $this->purchase = $purchase; $this->countableService = $countableService; $this->unitaryService = $unitaryService; $this->subscription = $subscription; $this->imputation = $imputation; $this->imputationType = $imputationType; $this->computer = $computer; $this->setTemplate('imputationInfo', 'use'); }
public function configure() { /*---------------------------------- WIDGETS CONFIGURATION ----------------------------------*/ foreach ($this->getOption('users', array()) as $user_id) { $this->widgetSchema['method_of_payment_id_' . $user_id] = new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ImputationMethodOfPayment'), 'add_empty' => false)); $this->validatorSchema['method_of_payment_id_' . $user_id] = new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('ImputationMethodOfPayment'))); $this->setDefaults(array('method_of_payment_id_' . $user_id => ParametersConfiguration::getDefault('default_method_of_payment'))); } foreach ($this->getOption('users', array()) as $user_id) { $this->widgetSchema['user_id_' . $user_id] = new sfWidgetFormInputText(); $this->validatorSchema['user_id_' . $user_id] = new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'required' => false)); $this->widgetSchema['user_id_' . $user_id]->setAttribute('value', $user_id); $this->widgetSchema['user_id_' . $user_id]->setAttribute('type', 'hidden'); } $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden(array(), array('readonly' => 'readonly')); $this->widgetSchema['act_id'] = new sfWidgetFormInputHidden(array(), array('readonly' => 'readonly')); $this->widgetSchema['moderator_id'] = new sfWidgetFormInputHidden(array(), array('readonly' => 'readonly')); $this->widgetSchema['imputation_type'] = new sfWidgetFormInputHidden(array(), array('readonly' => 'readonly')); $this->widgetSchema['comment'] = new sfWidgetFormTextarea(); $this->widgetSchema['date'] = new sfWidgetFormI18nDateTime(array('culture' => $this->getOption('culture'))); $this->widgetSchema['total']->setAttribute('size', 5); /*---------------------------------- VALIDATORS CONFIGURATION ----------------------------------*/ $this->validatorSchema['date']->setOption('required', true); $this->validatorSchema['date']->setMessage('invalid', 'The date/time format is invalid.'); $this->validatorSchema['user_id']->setOption('required', true); $this->validatorSchema['total']->setOption('required', true); $this->validatorSchema['account_id']->setOption('required', true); if ($this->getOption('imputation_type') != ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE) { $this->validatorSchema['room_id']->setOption('required', true); $this->validatorSchema['building_id']->setOption('required', true); $this->validatorSchema['act_id']->setOption('required', true); } /*--------------- MODIFICATION OF THE 'TOTAL' WIDGET IN 2 PARTICULAR CASE:-----------------*/ if ($this->getOption('imputation_type') == ImputationDefaultValues::COUNTABLE_SERVICE_TYPE || $this->getOption('imputation_type') == ImputationDefaultValues::SUBSCRIPTION_TYPE) { $this->widgetSchema->setLabel('total', 'Price'); } /*--------------------- MODIFICATION OF THE 'UNITY_ID' WIDGET IN 4 CASES:-------------------*/ if ($this->getOption('imputation_type') != ImputationDefaultValues::COUNTABLE_SERVICE_TYPE) { $this->widgetSchema['unity_id'] = new sfWidgetFormInputHidden(); } /*------------------------- ACCOUNTS WHOSE BELONGS TO THE USERS:----------------------------*/ $userAccounts = Doctrine::getTable('AccountUser')->findByUserId($this->getObject()->getUser()->getId()); $user_account_designations = array(0 => ''); foreach ($userAccounts as $userAccount) { if ($this->getOption('imputation_type') == ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE) { $user_account_designations[$userAccount->getAccount()->getId()] = $userAccount->getAccount()->getAct()->getDesignation(); } else { if ($userAccount->getAccount()->getMonetaryAccount() == 1) { $user_account_designations[$userAccount->getAccount()->getId()] = $userAccount->getAccount()->getAct()->getDesignation(); } } } $this->widgetSchema['account_id'] = new sfWidgetFormChoice(array('choices' => $user_account_designations, 'multiple' => false, 'expanded' => false)); $this->validatorSchema['account_id'] = new sfValidatorChoice(array('choices' => array_keys($user_account_designations)), array('invalid' => 'the account id is invalid')); foreach ($this->getOption('users', array()) as $user_id) { $userAccounts = Doctrine::getTable('AccountUser')->findByUserId($user_id); $user_account_designations = array(0 => ''); foreach ($userAccounts as $userAccount) { if ($this->getOption('imputation_type') == ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE) { $user_account_designations[$userAccount->getAccount()->getId()] = $userAccount->getAccount()->getAct()->getDesignation(); } else { if ($userAccount->getAccount()->getMonetaryAccount() == 1) { $user_account_designations[$userAccount->getAccount()->getId()] = $userAccount->getAccount()->getAct()->getDesignation(); } } } $this->widgetSchema['account_id_' . $user_id] = new sfWidgetFormChoice(array('choices' => $user_account_designations, 'multiple' => false, 'expanded' => false)); $this->validatorSchema['account_id_' . $user_id] = new sfValidatorChoice(array('choices' => array_keys($user_account_designations)), array('invalid' => 'the account id is invalid')); } /*--------------------------------- CORRESPONDING ACT:------------------------------------*/ if ($this->getOption('imputation_type') != ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE) { //Set the default act id: $this->widgetSchema->setDefault('act_id', $this->getObject()->getAct()->getId()); } /*------------------------------------------ LABELS --------------------------------------------*/ $this->widgetSchema->setLabel('date', 'Date and Time'); $this->widgetSchema->setLabel('moderator_id', 'Animator'); $this->widgetSchema->setLabel('account_id', 'Concerned Account'); if ($this->getOption('imputation_type') == ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE) { $this->widgetSchema->setLabel('method_of_payment_id', 'Paid by'); } else { $this->widgetSchema->setLabel('method_of_payment_id', 'Pay by'); } }
/** * * @param integer $type */ private static function getBuildingByType($type) { switch ($type) { case self::ACCOUNT_TRANSACTION_TYPE: return null; break; case self::PURCHASE_TYPE: return ParametersConfiguration::getDefault(self::DEFAULT_BUILDING); break; case self::COUNTABLE_SERVICE_TYPE: return ParametersConfiguration::getDefault(self::DEFAULT_BUILDING); break; case self::UNITARY_SERVICE_TYPE: return ParametersConfiguration::getDefault(self::DEFAULT_BUILDING); break; case self::SUBSCRIPTION_TYPE: return ParametersConfiguration::getDefault(self::DEFAULT_BUILDING); break; default: return null; } }
/** * * @param $parameters */ public static function buildAndSaveTransactionFrom($parameters) { /* --- Duplicate the parameters: --- */ $parameters_account_transaction = $parameters; /* --- Change the parameters: --- */ /* --- Unset those who do not correspond to an account transaction: --- */ $parameters_account_transaction = ImputationAccountTransaction::unsetFieldsByType($parameters_account_transaction, $parameters_account_transaction['imputation']['imputation_type']); /* --- Add the missing ones: --- */ $parameters_account_transaction['sum'] = $parameters_account_transaction['imputation']['total']; /* --- Modify those who need to be modified --- */ $parameters_account_transaction['imputation']['imputation_type'] = ImputationDefaultValues::ACCOUNT_TRANSACTION_TYPE; $parameters_account_transaction['imputation']['total'] = -$parameters_account_transaction['imputation']['total']; /* --- Create a form of type 'account transaction': --- */ $transaction = new ImputationAccountTransaction(); $transaction->getImputation()->setUserId($parameters_account_transaction['imputation']['user_id']); $form_account_transaction = new ImputationAccountTransactionForm($transaction, array('culture' => ParametersConfiguration::getDefault('default_language'))); //Bind the form to the new parameters: $form_account_transaction->bind($parameters_account_transaction); //Save it if it's valid: if ($form_account_transaction->isValid() && $parameters['imputation']['account_id'] != 0) { /* --- Decrement the corresponding account: --- */ $account = Doctrine::getTable('Account')->find($parameters['imputation']['account_id']); $account->setValue($account->getValue() - $parameters['imputation']['total']); $account->save(); $form_account_transaction->save(); return true; } else { return false; } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { //We check if there is modules which have not been activated: if ($this->getContext()->get('Kernel')->getUnsatisfiedDependencies()) { $this->getUser()->setFlash('error', 'Some modules are not activated because dependencies are missing. Please go to the configuration menu to correct theses issues.', false); } // ----------------------------------------------------------------------------------------------------------- // KYXAR 0006 - 30/06/2011 // Modification des libellés du nombre d'abonnements valides sur le tableau de bord $todayDate = strftime("%Y%m%d"); // KYXAR 0006 - 30/06/2011 // ----------------------------------------------------------------------------------------------------------- $beginningDate = strftime("%Y%m%d", mktime(0, 0, 0, date("m"), 1, date("Y"))); $endDate = strftime("%Y%m%d", mktime(0, 0, 0, date("m") + 1, 0, date("Y"))); $firstDayOfNextMonth = strftime("%Y%m%d", mktime(0, 0, 0, date("m") + 1, 1, date("Y"))); $numberOfValidSubscriptionsBeginning = 0; $numberOfValidSubscriptionsEnd = 0; $numberOfUsesPerCategory = array(); $numberOfUses = 0; $totalDuration = 0; /*We get the public categories*/ $publicCategories = Doctrine_Query::create()->select('a.*')->from('ActPublicCategory a')->orderBy('a.sort_order')->execute(); /*We count the number of visits*/ $numberVisits = Doctrine_Query::create()->from('Imputation i')->where('i.date >= ?', $beginningDate)->addWhere('i.date < ?', $firstDayOfNextMonth)->addWhere('i.imputation_type <> ?', 1)->count(); /*We count the number of unique visitors*/ $numberOfUniqueVisitors = Doctrine_Query::create()->from('Imputation i')->where('i.date >= ?', $beginningDate)->addWhere('i.date < ?', $firstDayOfNextMonth)->groupBy('i.user_id')->count(); $numberOfRegularVisitors = Doctrine_Query::create()->from('Imputation i')->where('i.date >= ?', $beginningDate)->addWhere('i.date < ?', $firstDayOfNextMonth)->groupBy('i.user_id, i.user_id HAVING COUNT(*)>1')->count(); /*We count the total of the checkout*/ $checkoutTotal = Doctrine_Query::create()->select('sum(i.total)')->from('Imputation i')->where('i.date >= ?', $beginningDate)->addWhere('i.date < ?', $firstDayOfNextMonth)->fetchArray(); /*We get all the subscriptions*/ $subscriptions = Doctrine_Query::create()->select('i.*')->from('Imputation i')->where('i.imputation_type = ?', "5")->execute(); /*For each subscription, we compare its end date to the beginning date and the end date*/ foreach ($subscriptions as $subscription) { $subscriptionFinalDateQuery = Doctrine::getTable('ImputationSubscription')->findOneByImputationId($subscription->getId()); // ----------------------------------------------------------------------------------------------------------- // KYXAR 0005 - 30/06/2011 // Correction du nombre d'abonnements valides $beginOfSubscription = strtotime($subscription->getDate()); $endOfSubscription = strtotime($subscriptionFinalDateQuery->getFinalDate()); if ($beginOfSubscription <= strtotime($todayDate) && $endOfSubscription >= strtotime($todayDate)) { $numberOfValidSubscriptionsBeginning++; } if ($beginOfSubscription <= strtotime($endDate) && $endOfSubscription >= strtotime($endDate)) { $numberOfValidSubscriptionsEnd++; } // FIN KYXAR 0005 - 30/06/2011 // ----------------------------------------------------------------------------------------------------------- } /*We get all the uses (expected the transaction on an account uses*/ $uses = Doctrine_Query::create()->select('i.*')->from('Imputation i')->where('i.date >= ?', $beginningDate)->addWhere('i.date < ?', $firstDayOfNextMonth)->addWhere('i.imputation_type <> ?', 1)->execute(); foreach ($publicCategories as $publicCategory) { $numberOfUsesPerCategory[$publicCategory->getId()] = 0; $timePerCategory[$publicCategory->getId()] = 0; } $numberOfUsesPerCategory[0] = 0; $timePerCategory[0] = 0; foreach ($uses as $use) { $numberOfUses++; if ($use->getUserId() != null) { $user = Doctrine::getTable('User')->findOneById($use->getUserId()); if ($user->getActPublicCategoryId() != null) { $numberOfUsesPerCategory[$user->getActPublicCategoryId()]++; } else { $numberOfUsesPerCategory[0]++; } } else { $numberOfUsesPerCategory[0]++; } } /*We get all the unitary services (services with a time)*/ $unitaryServices = Doctrine_Query::create()->select('i.*')->from('Imputation i')->where('i.imputation_type = ?', "4")->addWhere('i.date >= ?', $beginningDate)->addWhere('i.date < ?', $firstDayOfNextMonth)->execute(); foreach ($unitaryServices as $unitaryService) { $imputationUnitaryService = Doctrine::getTable('ImputationUnitaryService')->findOneByImputationId($unitaryService->getId()); $beginningTime = $imputationUnitaryService->getBeginningTime(); $endTime = $imputationUnitaryService->getEndTime(); $duration = round((strtotime($endTime) - strtotime($beginningTime)) / 3600, 1); if ($unitaryService->getUserId() != null) { $user = Doctrine::getTable('User')->findOneById($unitaryService->getUserId()); if ($user->getActPublicCategoryId() != null) { $timePerCategory[$user->getActPublicCategoryId()] += $duration; } else { $timePerCategory[0] += $duration; } } else { $timePerCategory[0] += $duration; } $totalDuration += $duration; } /*Send to the template*/ $this->beginningDate = $beginningDate; $this->endDate = $endDate; $this->numberOfVisits = $numberVisits; $this->numberOfUniqueVisitors = $numberOfUniqueVisitors; $this->numberOfRegularVisitors = $numberOfRegularVisitors; $this->checkoutTotal = round($checkoutTotal[0]['sum'], 2); $this->numberOfValidSubscriptionsBeginning = $numberOfValidSubscriptionsBeginning; $this->numberOfValidSubscriptionsEnd = $numberOfValidSubscriptionsEnd; $this->numberOfUsesPerCategory = $numberOfUsesPerCategory; $this->publicCategories = $publicCategories; $this->numberOfUses = $numberOfUses; $this->totalDuration = $totalDuration; $this->timePerCategory = $timePerCategory; ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $defaultCurrencyId = ParametersConfiguration::getDefault('default_currency'); $this->defaultCurrency = Doctrine::getTable('Unity')->findOneById($defaultCurrencyId)->getDesignation(); }
week : "<?php echo __('week'); ?> ", day : "<?php echo __('day'); ?> " }, minTime: "<?php $time = ParametersConfiguration::getDefault('reservation_min_time'); echo $time ? $time : 8; ?> ", maxTime: "<?php $time = ParametersConfiguration::getDefault('reservation_max_time'); echo $time ? $time : 18; ?> ", allDaySlot: false, axisFormat: "<?php echo __('HH:mm{ - HH:mm} '); ?> ", header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, aspectRatio: 2, events : {
/** * Diplays the current values for the selected predefined multiple service * * @param sfWebRequest $request * @param sfForm $form */ public function executeEditMultipleService(sfWebRequest $request) { $this->forward404Unless($multipleService = Doctrine::getTable('Act')->find(array($request->getParameter('id'))), sprintf('Object purchase does not exist (%s).', $request->getParameter('id'))); if ($multipleService['monetary_account'] == "0") { $monetaryAccount = null; } else { $monetaryAccount = 1; } $this->values = array('designation' => $multipleService['designation'], 'shortened_designation' => $multipleService['shortened_designation'], 'monetary_account' => $monetaryAccount, 'quantity' => $multipleService['quantity'], 'unity_id' => $multipleService['unity_id'], 'comment' => $multipleService['comment'], 'act_type_id' => $multipleService['act_type_id']); $this->multipleServiceId = $request->getParameter('id'); //Used for the redirection if ($request->getParameter('index')) { $this->index = 1; } else { $this->index = 0; } $this->form = new MultipleServiceForm($this->values); $this->form->setWidget('unity_id', new sfWidgetFormInputHidden()); if (!$multipleService['monetary_account']) { $this->unity = Doctrine::getTable('Unity')->findOneById($multipleService['unity_id']); } else { ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $defaultCurrencyId = ParametersConfiguration::getDefault('default_currency'); $this->unity = Doctrine::getTable('Unity')->findOneById($defaultCurrencyId)->getShortenedDesignation(); } $this->form->getWidget('designation')->setAttribute('readonly', 'readonly'); $this->form->getWidget('monetary_account')->setAttribute('readonly', 'readonly'); $this->form->getWidget('shortened_designation')->setAttribute('readonly', 'readonly'); $this->form->getWidget('quantity')->setAttribute('readonly', 'readonly'); }
if($(this).val() == "<?php echo ImputationDefaultValues::getAccountMethodId(); ?> "){ $("#imputation_account_transaction_account_to_pay_id").css("visibility","visible"); }else{ $("#imputation_account_transaction_account_to_pay_id").css("visibility","hidden"); } }); $("#imputation_account_transaction_imputation_method_of_payment_id").ready(function(){ if("<?php echo ParametersConfiguration::getDefault('default_method_of_payment'); ?> " == "<?php echo ImputationDefaultValues::getAccountMethodId(); ?> "){ $("#imputation_account_transaction_account_to_pay_id").css("visibility","visible"); }else{ $("#imputation_account_transaction_account_to_pay_id").css("visibility","hidden"); } }); $("#imputation_account_transaction_imputation_total").focus(function(){ changeTotal(); });
public function executeUpdateActPrices(sfWebRequest $request) { $acts = Doctrine::getTable('Act')->createQuery()->select('a.*')->from('Act a')->where('a.disabled <> 1')->execute(); $publicCategories = Doctrine::getTable('ActPublicCategory')->createQuery()->select('ap.*')->from('ActPublicCategory ap')->orderBy('ap.sort_order')->execute(); $noError = 1; $errorArray = array(); //We get the modified cells $modifiedCellsRequest = $request->getParameter('modifiedCells'); $modifiedCells = explode(",", $modifiedCellsRequest); //If some cells have been modified if ($modifiedCellsRequest != null) { foreach ($modifiedCells as $modifiedCell) { $exploded = explode("_", $modifiedCell); $actId = $exploded[1]; $actPublicCategoryId = $exploded[2]; $newPrice = $request->getParameter('price_' . $actId . '_' . $actPublicCategoryId); $newPrice = strtr($newPrice, ",", "."); $convert = array(" " => ""); $newPrice = strtr($newPrice, $convert); $correctInsert = 0; if (is_numeric($newPrice)) { $priceToInsert = $newPrice; $correctInsert = 1; } else { if (!strcmp($newPrice, "")) { $priceToInsert = -1; $correctInsert = 1; } else { $this->getUser()->setFlash('error', 'You made a mistake on one or several price(s). If you have any problem, click on the Help button.', false); $noError = 0; $errorArray[$actId][$actPublicCategoryId] = $newPrice; } } if ($correctInsert) { $updatedActPrice = Doctrine::getTable('ActPrice')->findOneByActIdAndActPublicCategoryId($actId, $actPublicCategoryId); $updatedActPrice->setValue($priceToInsert); $updatedActPrice->save(); } } if ($noError) { $this->getUser()->setFlash('notice', 'The prices have been updated.', false); } } $actPrices_query = Doctrine_Query::create()->select('a.*')->from('ActPrice a'); $actPrices_res = $actPrices_query->fetchArray(); $actPrices = array(); foreach ($actPrices_res as $price) { $actPrices[$price['act_id']][$price['act_public_category_id']] = $price['value']; } /*Redirect*/ ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login')); $defaultCurrencyId = ParametersConfiguration::getDefault('default_currency'); $this->defaultCurrency = Doctrine::getTable('Unity')->findOneById($defaultCurrencyId)->getDesignation(); $this->price = $actPrices; $this->acts = $acts; $this->publicCategories = $publicCategories; $this->errorArray = $errorArray; $this->setTemplate('index'); }
public function executeRefreshUnities(sfWebRequest $request) { $this->form = new DefaultParametersForm(array('default_currency' => ParametersConfiguration::getDefault('default_currency'))); }