public function retrieveSoldes() { // filtre de base pour les transactions $q = TransactionTable::getInstance()->createQuery('t'); $q->select('SUM(t.montant) as total')->where('t.compte_id = ?', $this->getPrimaryKey())->andWhere('t.note_de_frais_id IS NULL AND t.deleted_at IS NULL')->groupBy('t.compte_id'); $qmax = clone $q; $qmin = clone $q; // transactions rapprochées $q->andWhere('t.date_rapprochement IS NOT NULL'); $res = $q->execute(); if (count($res) == 0) { $rapproche = $this->soldes['rapproche'] = 0; } else { $rapproche = $this->soldes['rapproche'] = $res[0]['total']; } // total des dépenses non rapprochées $qmin->andWhere('t.date_rapprochement IS NULL AND t.montant < 0'); $res = $qmin->execute(); if (count($res) == 0) { $minimum = 0; } else { $minimum = $res[0]['total']; } // total des recettes non rapprochées $qmax->andWhere('t.date_rapprochement IS NULL AND t.montant > 0'); $res = $qmax->execute(); if (count($res) == 0) { $maximum = 0; } else { $maximum = $res[0]['total']; } $this->soldes['actuel'] = $rapproche + $minimum + $maximum; $this->soldes['minimum'] = $rapproche + $minimum; $this->soldes['maximum'] = $rapproche + $maximum; }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->asso = $this->getRoute()->getObject(); $this->checkAuthorisation($this->asso); $this->cheques = TransactionTable::getInstance()->getChequesEmis($this->asso)->execute(); $this->getResponse()->setSlot('current_asso', $this->asso); }
public function executeIndex(sfWebRequest $request) { $this->asso = $this->getRoute()->getObject(); $this->checkAuthorisation($this->asso); $this->note_de_frais = NoteDeFraisTable::getInstance()->getAllForAsso($this->asso)->execute(); $this->transactions = TransactionTable::getInstance()->getRemboursablesForAsso($this->asso)->execute(); $this->getResponse()->setSlot('current_asso', $this->asso); }
public function addAchatFromId($achat) { $transaction = TransactionTable::getInstance()->find($achat); if ($transaction == false) { return false; } $this->addAchat($transaction); return $transaction; }
public function configure() { $this->widgetSchema['asso_id'] = new SfWidgetFormInputHidden(); $this->widgetSchema['transactions'] = new portailWidgetFormDoctrineChoice(array('label' => 'Achats', 'model' => 'Transaction', 'query' => TransactionTable::getInstance()->getRemboursablesForAsso($this->getObject()->getAsso()), 'add_empty' => false, 'multiple' => true, 'method' => 'noteDeFraisRepr', 'renderer_class' => 'portailWidgetFormSelectCheckbox', 'renderer_options' => array('dynamic_attributes' => array('data-montant' => 'getMontantAbsolute', 'data-nom' => 'getMoyenCommentaire')))); $this->validatorSchema['transactions'] = new sfValidatorDoctrineChoice(array('model' => 'Transaction', 'query' => TransactionTable::getInstance()->getRemboursablesForAsso($this->getObject()->getAsso()), 'multiple' => true, 'min' => 1)); $this->validatorSchema['transaction_id'] = new sfValidatorPass(); // on ajoute tous les champs liés à la transaction $this->widgetSchema['moyen_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'TransactionMoyen', 'add_empty' => false)); $this->validatorSchema['moyen_id'] = new sfValidatorDoctrineChoice(array('model' => 'TransactionMoyen')); $this->widgetSchema['compte_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'CompteBanquaire', 'query' => CompteBanquaireTable::getInstance()->getAllForAsso($this->getObject()->getAsso()), 'add_empty' => false)); $this->validatorSchema['compte_id'] = new sfValidatorDoctrineChoice(array('model' => 'CompteBanquaire', 'query' => CompteBanquaireTable::getInstance()->getAllForAsso($this->getObject()->getAsso()))); $this->widgetSchema['moyen_commentaire'] = new sfWidgetFormInput(array(), array('placeholder' => 'n° du chèque ou laisser vide')); $this->validatorSchema['moyen_commentaire'] = new sfValidatorString(array('required' => false)); unset($this['created_at'], $this['updated_at'], $this['deleted_at']); }
public function executeOnpay(sfWebRequest $request) { $pay_for = $request->getGetParameter('pay_for'); if (!is_numeric($pay_for)) { throw new sfException('wrong argument for onpay'); } $transaction = TransactionTable::getInstance()->findOneById($pay_for); $onpay = OnPay::forTransaction($transaction); $result = $onpay->processApiRequest($request->getGetParameter('type'), $request->getGetParameter('order_amount'), $request->getGetParameter('order_currency'), $pay_for, $request->getGetParameter('md5'), $request->getGetParameter('onpay_id'), $request->getGetParameter('balance_amount'), $request->getGetParameter('balance_currency'), $request->getGetParameter('exchange_rate'), $request->getGetParameter('paymentDateTime')); $this->getResponse()->setContentType('text/plain'); return $this->renderText($result); }
public function getSumPoste() { $s = TransactionTable::getInstance()->createQuery('t')->select('SUM(t.montant) AS sumPoste')->where('t.budget_poste_id=?', $this->getPrimaryKey())->andWhere('t.deleted_at IS NULL')->fetchOne(); return $s['sumPoste']; }
public function processApiRequest($type, $order_amount, $order_currency, $pay_for, $md5, $onpay_id = null, $balance_amount = null, $balance_currency = null, $exchange_rate = null, $paymentDateTime = null) { $rezult = ''; $error = ''; //проверяем чек запрос if ($type == 'check') { // проверим совпадает ли сумма и валюта операции if ($this->sum == $order_amount and $order_currency == $this->currency) { //выдаем ответ OK на чек запрос $rezult = $this->answer($type, 0, $pay_for, $order_amount, $order_currency, 'OK'); } else { $rezult = $this->answer($type, 1, $pay_for, $order_amount, $order_currency, 'Wrong sum or currency'); } } //проверяем запрос на пополнение if ($type == 'pay') { //производим проверки входных данных if (empty($onpay_id)) { $error .= "Не указан id<br>"; } else { if (!is_numeric(intval($onpay_id))) { $error .= "Параметр не является числом<br>"; } } if (empty($order_amount)) { $error .= "Не указана сумма<br>"; } else { if (!is_numeric($order_amount)) { $error .= "Параметр не является числом<br>"; } } if (empty($balance_amount)) { $error .= "Не указана сумма<br>"; } else { if (!is_numeric(intval($balance_amount))) { $error .= "Параметр не является числом<br>"; } } if (empty($balance_currency)) { $error .= "Не указана валюта<br>"; } else { if (strlen($balance_currency) > 4) { $error .= "Параметр слишком длинный<br>"; } } if (empty($order_currency)) { $error .= "Не указана валюта<br>"; } else { if (strlen($order_currency) > 4) { $error .= "Параметр слишком длинный<br>"; } } if (empty($exchange_rate)) { $error .= "Не указана сумма<br>"; } else { if (!is_numeric($exchange_rate)) { $error .= "Параметр не является числом<br>"; } } //если нет ошибок if (!$error) { if (is_numeric($pay_for)) { //Если pay_for - число $sum = floatval($order_amount); if (($transaction = TransactionTable::getInstance()->findOneById($pay_for)) instanceof Transaction) { //создаем строку хэша с присланных данных $md5fb = strtoupper(md5($type . ";" . $pay_for . ";" . $onpay_id . ";" . $order_amount . ";" . $order_currency . ";" . $this->private_code)); //сверяем строчки хеша (присланную и созданную нами) if ($md5fb != $md5) { $rezult = $this->answerpay($type, 8, $pay_for, $order_amount, $order_currency, 'Md5 signature is wrong. Expected ' . $md5fb, $onpay_id); } else { $rezult_balance = User::addFundsFin($transaction); //если оба запроса прошли успешно выдаем ответ об удаче, если нет, то о том что операция не произошла if ($rezult_balance) { $rezult = $this->answerpay($type, 0, $pay_for, $order_amount, $order_currency, 'OK', $onpay_id); } else { $rezult = $this->answerpay($type, 9, $pay_for, $order_amount, $order_currency, 'Error in mechant database queries: operation or balance tables error', $onpay_id); } } } else { $rezult = $this->answerpay($type, 10, $pay_for, $order_amount, $order_currency, 'Cannot find any pay rows acording to this parameters: wrong payment', $onpay_id); } } else { //Если pay_for - не правильный формат $rezult = $this->answerpay($type, 11, $pay_for, $order_amount, $order_currency, 'Error in parameters data', $onpay_id); } } else { //Если есть ошибки $rezult = $this->answerpay($type, 12, $pay_for, $order_amount, $order_currency, 'Error in parameters data: ' . $error, $onpay_id); } } return $rezult; }
public function executePdf(sfWebRequest $request) { $compte = $this->getRoute()->getObject(); $this->checkAuthorisation($compte->getAsso()); $transactions = TransactionTable::getInstance()->getJournalForCompte($compte)->orderBy('q.date_transaction ASC')->execute(); $html = $this->getPartial('transaction/pdf', compact(array('transactions', 'compte'))); $nom = date('Y-m-d-H-i-s'); $doc = new Document(); $doc->setNom('Export du journal des transactions'); $doc->setAsso($compte->getAsso()); $doc->setUser($this->getUser()->getGuardUser()); $doc->setTypeFromSlug('transactions'); $path = $doc->generatePDF($compte->getAsso()->getName() . ' : Journal du compte ' . $compte->getNom(), $nom, $html); $doc->save(); header('Content-type: application/pdf'); readfile($path); return sfView::NONE; }