Пример #1
0
 public function actionOpenbalance()
 {
     $model = new Transactions();
     if (isset($_POST['account'])) {
         $year = $_POST['year'];
         $date = "{$year}-01-01 00:00:01";
         $accountArr = $_POST['account'];
         $balanceArr = $_POST['bal'];
         foreach ($accountArr as $index => $account) {
             $sum = $balanceArr[$index];
             if ($account) {
                 $submodel = new Transactions();
                 $submodel->refnum1 = '';
                 $submodel->valuedate = $date;
                 $submodel->details = Yii::t('app', "Opening Balance");
                 $submodel->type = \app\helpers\Linet3Helper::getSetting('transactionType.openBalance');
                 $submodel->currency_id = \app\helpers\Linet3Helper::getSetting('company.cur');
                 $submodel->owner_id = Yii::$app->user->id;
                 $submodel->linenum = 0;
                 $submodel->addDoubleLine($account, \app\helpers\Linet3Helper::getSetting('company.acc.openbalance'), $sum);
                 //$submodel->num;
             }
         }
         \Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Open Balance saved'));
         //$this->redirect(array('OpenBalance'));
     }
     return $this->render('opbalance', array('model' => $model));
 }
Пример #2
0
 public function actionCreate($type = 0)
 {
     $model = new FormOutcome();
     if ($type == 1) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.payvat");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     if ($type == 2) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.natinspay");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     if ($type == 3) {
         $model->account_id = \app\helpers\Linet3Helper::getSetting("company.acc.pretax");
         $model->sum = Accounts::findOne($model->account_id)->getBalance();
     }
     // Uncomment the following line if AJAX validation is needed
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
         return \yii\widgets\ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post())) {
         if ($model->transaction()) {
             \Yii::$app->getSession()->setFlash('success', Yii::t('app', 'transaction Success'));
         }
     }
     return $this->render('create', array('model' => $model));
 }
Пример #3
0
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     $transAction = new Transactions();
     $transAction->type = \app\helpers\Linet3Helper::getSetting('transactionType.manual');
     if (isset($this->sourcepos) && (double) $this->sourcepos != 0) {
         $sum = $this->sourcepos;
     } else {
         $sum = $this->sourceneg * -1;
     }
     $transAction->owner_id = Yii::$app->user->id;
     $transAction->linenum = 1;
     $transAction->currency_id = $this->currency_id;
     $transAction->refnum1 = $this->refnum1_ids;
     $transAction->refnum2 = $this->refnum2;
     $transAction->details = $this->details;
     $transAction->valuedate = $this->valuedate;
     $trans = Yii::$app->db->beginTransaction(\yii\db\Transaction::READ_UNCOMMITTED);
     //-shuld start transaction here so lets lock down
     try {
         $transAction = $transAction->addSingleLine($this->account_id, $sum);
         if ($transAction) {
             foreach ($this->ops as $i => $acc) {
                 if (isset($this->sumpos[$i]) && (double) $this->sumpos[$i] != 0) {
                     $smallsum = $this->sumpos[$i];
                 } else {
                     $smallsum = $this->sumneg[$i] * -1;
                 }
                 if (abs($smallsum) > 0.0001) {
                     $transAction = $transAction->addSingleLine($acc, $smallsum, $this->valuedates[$i]);
                 }
             }
         }
         //commit it here
         $trans->commit();
     } catch (\Exception $e) {
         $trans->rollBack();
         $message = $e->getMessage();
         $this->addError('details', $message);
         return false;
     }
     //put your code here
     return true;
 }
Пример #4
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $class = get_class($this);
     if ($class == 'Accounts') {
         if (Accounts::findOne($this->id)) {
             $this->isNewRecord = false;
         }
     }
     $a = parent::save($runValidation, $attributes);
     if ($a) {
         //if (isset($_POST['Files'])) {
         //$this->attributes = $_POST['Files'];
         $tmps = \yii\web\UploadedFile::getInstancesByName('Files');
         // proceed if the images have been set
         if (isset($tmps) && count($tmps) > 0) {
             \Yii::info('saved');
             // go through each uploaded image
             $configPath = \app\helpers\Linet3Helper::getSetting("company.path");
             foreach ($tmps as $image => $pic) {
                 $img_add = new Files();
                 $img_add->name = $pic->name;
                 //it might be $img_add->name for you, filename is just what I chose to call it in my model
                 $img_add->path = "files/";
                 $img_add->parent_type = get_class($this);
                 $img_add->parent_id = $this->id;
                 // this links your picture model to the main model (like your user, or profile model)
                 $img_add->save();
                 // DONE
                 if ($pic->saveAs($img_add->getFullFilePath())) {
                     // add it to the main model now
                 } else {
                     echo 'Cannot upload!';
                 }
             }
             if (isset($_FILES)) {
                 Yii::info(print_r($_FILES, true));
                 unset($_FILES);
                 $tmps = \yii\web\UploadedFile::reset();
             }
             //}
         }
     }
     //endFile
     return $a;
 }
Пример #5
0
 public function save($runValidation = true, $attributes = NULL)
 {
     //adam:
     if ($this->eavType == 'boolean') {
         if ($this->value == '1') {
             $this->value = 'true';
         } else {
             $this->value = 'false';
         }
     } else {
         if ($this->eavType == 'file') {
             $configPath = Linet3Helper::getSetting("company.path");
             $a = \yii\web\UploadedFile::getInstanceByName('Settings[' . $this->id . '][value]');
             //var_dump($a);
             //exit;
             if ($a) {
                 $this->value = $a;
                 $ext = $this->value->extension;
                 //$fileName = $yiiBasepath."/files/".$configPath."/settings/".$this->id.".".$ext;
                 //echo $this->id.get_class($this);
                 $logo = new \app\models\Files();
                 $logo->name = $this->id . "." . $ext;
                 //it might be $img_add->name for you, filename is just what I chose to call it in my model
                 $logo->path = "settings/";
                 $logo->parent_type = get_class($this);
                 $logo->parent_id = $this->id;
                 // this links your picture model to the main model (like your user, or profile model)
                 $logo->public = true;
                 $id = $logo->save();
                 // DONE
                 //echo $logo->id;
                 //Yii::$app->end();
                 if ($this->value->saveAs($logo->getFullFilePath())) {
                     $this->value = $logo->hash;
                     //"/files/".$configPath."/settings/".$this->id.".".$ext;
                 }
                 //Yii::$app->end();
             }
         }
     }
     return parent::save($runValidation, $attributes);
 }
Пример #6
0
 public function send()
 {
     //Yii::import('application.extensions.smtpmail.PHPMailer');
     $mailer = new \yii\swiftmailer\Mailer(["transport" => ['class' => 'Swift_SmtpTransport', 'host' => \app\helpers\Linet3Helper::getSetting('company.mail.server'), 'username' => \app\helpers\Linet3Helper::getSetting('company.mail.user'), 'password' => \app\helpers\Linet3Helper::getSetting('company.mail.password'), 'port' => \app\helpers\Linet3Helper::getSetting('company.mail.port'), 'encryption' => \app\helpers\Linet3Helper::getSetting('company.mail.ssl') ? 'tls' : '']]);
     $mail = $mailer->compose('layouts/html', ['content' => $this->body]);
     //$mail->SetFrom($this->from);
     //echo $this->files;
     if ($this->files != '') {
         $file = Files::findOne($this->files);
         if ($file != null) {
             //echo $file->getFullPath().";;".$file->name;
             $mail->attach($file->getFullFilePath(), ["fileName" => $file->name]);
         }
     }
     $mail->setFrom(\app\helpers\Linet3Helper::getSetting('company.mail.address'))->setTo($this->to)->setSubject($this->subject);
     if ($this->cc != '') {
         $mail->setCc($this->cc);
     }
     if ($this->bcc != '') {
         $mail->setBcc($this->bcc);
     }
     //$mail->AddCC($this->cc); //.$this->cc
     //$mail->AddBcc($this->bcc);
     //$mail->
     //$mail->setHtmlBody($this->body);
     //$mail;
     if (!$mail->send()) {
         //echo "Mailer Error: " . $mail->ErrorInfo;
         throw new Exception(Yii::t('app', "Mailer Error: ") . $mail->ErrorInfo . $mail->Username);
     } else {
         $this->sent++;
         $this->save();
         if (!\app\helpers\Linet3Helper::isConsole()) {
             \Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Message sent!'));
         }
         //echo "Message sent!";
     }
     //*/
     //Yii::$app->end();
 }
Пример #7
0
 public function save()
 {
     //print_r($this->Deposit);
     $num = 0;
     //$linenum=1;
     $tranType = \app\helpers\Linet3Helper::getSetting('transactionType.chequedeposit');
     if ($this->refnum == '' || $this->date == '' || !is_array($this->Deposit)) {
         return false;
     }
     $accout = new Transactions();
     $accout->type = $tranType;
     $accout->refnum1 = '';
     //$this->refnum;
     $accout->refnum2 = $this->refnum;
     $accout->details = Yii::t('app', 'Deposit') . " #" . $this->refnum;
     $accout->valuedate = $this->date . $this->refnum;
     $accout->owner_id = Yii::$app->user->id;
     $accout->linenum = 1;
     $transaction = Yii::$app->db->beginTransaction(\yii\db\Transaction::READ_UNCOMMITTED);
     //-shuld start transaction here
     try {
         foreach ($this->Deposit as $line => $val) {
             list($a, $b) = explode(',', $line);
             $cheq = Doccheques::findOne(array("doc_id" => $a, "line" => $b));
             $oppt_acc = PaymentType::findOne($cheq->type)->oppt_account_id;
             $accout->currency_id = $cheq->currency_id;
             $accout->addDoubleLine($oppt_acc, $this->account_id, $cheq->sum);
             $cheq->bank_refnum = $num;
             $cheq->save();
         }
         $transaction->commit();
     } catch (\Exception $e) {
         $transaction->rollBack();
         $message = $e->getMessage();
         $this->addError('refnum', $message);
     }
     return true;
     //num
 }
Пример #8
0
 public function transaction()
 {
     if ($this->validate()) {
         $num = 0;
         $line = 1;
         $tranType = \app\helpers\Linet3Helper::getSetting("transactionType.supplierPayment");
         $tran = new Transactions();
         $tran->num = $num;
         $tran->type = $tranType;
         $tran->refnum1 = $this->refnum_ids;
         $tran->refnum2 = '';
         $tran->valuedate = $this->date;
         $tran->details = $this->details;
         $tran->currency_id = $this->currency_id;
         $tran->owner_id = Yii::$app->user->id;
         $tran->linenum = $line;
         $trans = Yii::$app->db->beginTransaction(\yii\db\Transaction::READ_UNCOMMITTED);
         //-shuld start transaction here so lets lock down
         try {
             $tran->addSingleLine($this->account_id, $this->sum * -1);
             $tran->addSingleLine($this->opp_account_id, $this->sum * 1);
             if ((int) $this->src_tax != 0) {
                 $tran->addDoubleLine(5, $this->account_id, $this->src_tax);
             }
             //commit it here
             $trans->commit();
         } catch (\Exception $e) {
             $trans->rollBack();
             $message = $e->getMessage();
             $this->addError('details', $message);
             return false;
         }
         $this->saveRef($num, $this->sum);
         return true;
     }
     return false;
 }
Пример #9
0
 public function actionLinet2import()
 {
     $model = new FormLinet2Import();
     if (isset($_POST['FormLinet2Import'])) {
         $configPath = \app\helpers\Linet3Helper::getSetting("company.path");
         $file = Company::getFilePath() . "linet2.bak";
         $model->file = $_POST['FormLinet2Import']['file'];
         $model->file = \yii\web\UploadedFile::getInstance($model, 'file');
         if ($model->file === null) {
             throw new \yii\web\HttpException(501, Yii::t('app', 'Error in request.'));
         }
         //no file
         if ($model->file->saveAs($file)) {
             $model->file = $file;
             $model->import();
             //$model->read();
         }
     }
     return $this->render('linet2Import', array('model' => $model));
     Yii::$app->end();
 }
Пример #10
0
 public function pay()
 {
     $this->dates();
     $date = $this->to_date;
     /*
               $tnum = Transaction(0, TRAN_PRETAX, IRS, $ref1, $ref2, $date, $details, $this->tax_sum);
               $tnum = Transaction($tnum, TRAN_PRETAX, PRETAX, $ref1, $ref2, $date, $details, $this->tax_sum * -1.0);
               $tnum = Transaction($tnum, TRAN_PRETAX, IRS, $ref1, $ref2, $date, $details, $this->custtax_total);
               $tnum = Transaction($tnum, TRAN_PRETAX, CUSTTAX, $ref1, $ref2, $date, $details, $this->custtax_total * -1.0);
     */
     $irs = \app\helpers\Linet3Helper::getSetting('company.acc.irs');
     $pretax = \app\helpers\Linet3Helper::getSetting('company.acc.pretax');
     $custtax = \app\helpers\Linet3Helper::getSetting('company.acc.custtax');
     $cur = \app\helpers\Linet3Helper::getSetting('company.cur');
     $owner = Yii::$app->user->id;
     $line = 1;
     $accout = new Transactions();
     $accout->account_id = $irs;
     //IRS
     $accout->type = 14;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'tax') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->tax_sum;
     $line++;
     $num = $accout->save();
     $accout = new Transactions();
     $accout->account_id = $pretax;
     //PRETAX
     $accout->type = 14;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'tax') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->tax_sum * -1;
     $line++;
     $accout->save();
     $accout = new Transactions();
     $accout->account_id = $irs;
     //IRS
     $accout->type = 14;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'tax') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->custtax_total;
     $line++;
     $accout->save();
     $accout = new Transactions();
     $accout->account_id = $custtax;
     //CUSTTAX
     $accout->type = 14;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'tax') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->custtax_total * -1.0;
     $line++;
     $accout->save();
 }
Пример #11
0
 protected function end()
 {
     //A1    type
     //N9    vatid
     $companyid = \app\helpers\Linet3Helper::getSetting('company.vat.id');
     return sprintf("Z%09d", $companyid);
 }
Пример #12
0
 public static function pdfDoc($model)
 {
     $yiiBasepath = Yii::$app->basePath;
     $yiiUser = \app\helpers\Linet3Helper::getUserId();
     //$configPath = app\helpers\Linet3Helper::getSetting("company.path");
     $user = User::findOne($yiiUser);
     if (!$user->hasCert()) {
         //create new
         $settings = array('commonName' => $user->username, 'emailAddress' => $user->email);
         if (\app\helpers\Linet3Helper::getSetting('company.en.city') != '') {
             $settings['localityName'] = \app\helpers\Linet3Helper::getSetting('company.en.city');
         }
         if (\app\helpers\Linet3Helper::getSetting('company.en.name') != '') {
             $settings['organizationName'] = \app\helpers\Linet3Helper::getSetting('company.en.name');
         }
         $ssl = new \app\helpers\SSLHelper($settings);
         $filename = $user->getCertFilePath();
         \app\helpers\Linet3Helper::setSetting('company.' . $yiiUser . '.certpasswd', $ssl->createUserCert($filename));
         //$user->save();
     }
     $configCertpasswd = \app\helpers\Linet3Helper::getSetting('company.' . $yiiUser . '.certpasswd');
     $name = $model->docType->name . "-" . "{$model->docnum}.pdf";
     $file = PrintDoc::findFile($model, $name);
     if (!$file) {
         $model->preview = 2;
         $docfile = PrintDoc::printMe($model);
         /*//adam
           $file = new Files();
           $file->name = $name;
           $file->path = "docs/";
           $file->parent_type = get_class($model);
           $file->parent_id = $model->id;
           $file->hidden = 1;
           $file->public = 0;
           $file->save();
           $file->writeFile($docfile);
           exit;
           //adam*/
         //$mPDF1 = new Pdf;
         //$mPDF1->execute(['WriteHTML' => $docfile]);
         $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'methods' => ['SetFooter' => ['Linet 3.1 Accounting Software']]]);
         $mpdf = $pdf->api;
         //$mpdf->fonttrans['freeserif'] = 'freeserif2';
         //$mpdf->PDFAauto = true;
         $mpdf->WriteHtml($docfile);
         $file = new Files();
         $file->name = $name;
         $file->path = "docs/";
         $file->parent_type = get_class($model);
         $file->parent_id = $model->id;
         $file->hidden = 1;
         $file->public = 0;
         $file->save();
         //var_dump($file->getErrors());
         //exit;
         $file->writeFile($mpdf->output("bla", "S"));
     }
     $name = $model->docType->name . "-" . "{$model->docnum}-signed.pdf";
     $doc_file = PrintDoc::findFile($model, $name);
     if (!$doc_file) {
         //'digi';//
         $cerfile = User::getCertFilePath($yiiUser);
         //loads a sample PDF file
         Yii::$classMap['Farit_Pdf'] = $yiiBasepath . '/vendor/Farit/Pdf.php';
         Yii::$classMap['Farit_Pdf_ElementRaw'] = $yiiBasepath . '/vendor/Farit/ElementRaw.php';
         Yii::$classMap['Zend_Memory'] = $yiiBasepath . '/vendor/Zend/Memory.php';
         Yii::$classMap['Zend_Memory_Manager'] = $yiiBasepath . '/vendor/Zend/Memory/Manager.php';
         Yii::$classMap['Zend_Memory_Container'] = $yiiBasepath . '/vendor/Zend/Memory/Container.php';
         Yii::$classMap['Zend_Memory_Container_Interface'] = $yiiBasepath . '/vendor/Zend/Memory/Container/Interface.php';
         Yii::$classMap['Zend_Memory_Container_Locked'] = $yiiBasepath . '/vendor/Zend/Memory/Container/Locked.php';
         Yii::$classMap['Zend_Pdf'] = $yiiBasepath . '/vendor/Zend/Pdf.php';
         Yii::$classMap['Zend_Pdf_Parser'] = $yiiBasepath . '/vendor/Zend/Pdf/Parser.php';
         Yii::$classMap['Zend_Pdf_Page'] = $yiiBasepath . '/vendor/Zend/Pdf/Page.php';
         Yii::$classMap['Zend_Pdf_UpdateInfoContainer'] = $yiiBasepath . '/vendor/Zend/Pdf/UpdateInfoContainer.php';
         Yii::$classMap['Zend_Pdf_Target'] = $yiiBasepath . '/vendor/Zend/Pdf/Target.php';
         Yii::$classMap['Zend_Pdf_Destination'] = $yiiBasepath . '/vendor/Zend/Pdf/Destination.php';
         Yii::$classMap['Zend_Pdf_Destination_Zoom'] = $yiiBasepath . '/vendor/Zend/Pdf/Destination/Zoom.php';
         Yii::$classMap['Zend_Pdf_Destination_Explicit'] = $yiiBasepath . '/vendor/Zend/Pdf/Destination/Explicit.php';
         Yii::$classMap['Zend_Pdf_RecursivelyIteratableObjectsContainer'] = $yiiBasepath . '/vendor/Zend/Pdf/RecursivelyIteratableObjectsContainer.php';
         Yii::$classMap['Zend_Pdf_StringParser'] = $yiiBasepath . '/vendor/Zend/Pdf/StringParser.php';
         Yii::$classMap['Zend_Pdf_ElementFactory'] = $yiiBasepath . '/vendor/Zend/Pdf/' . 'ElementFactory' . '.php';
         Yii::$classMap['Zend_Pdf_ElementFactory_Interface'] = $yiiBasepath . '/vendor/Zend/Pdf/ElementFactory/' . 'Interface' . '.php';
         Yii::$classMap['Zend_Pdf_ElementFactory_Proxy'] = $yiiBasepath . '/vendor/Zend/Pdf/ElementFactory/Proxy.php';
         Yii::$classMap['Zend_Pdf_Element_Reference_Table'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Reference/Table.php';
         Yii::$classMap['Zend_Pdf_Element_Reference_Context'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Reference/Context.php';
         Yii::$classMap['Zend_Pdf_Element_Dictionary'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Dictionary.php';
         Yii::$classMap['Zend_Pdf_Element'] = $yiiBasepath . '/vendor/Zend/Pdf/Element.php';
         Yii::$classMap['Zend_Pdf_Element_Object'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Object.php';
         Yii::$classMap['Zend_Pdf_Element_Null'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Null.php';
         Yii::$classMap['Zend_Pdf_Element_Name'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Name.php';
         Yii::$classMap['Zend_Pdf_Element_Numeric'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Numeric.php';
         Yii::$classMap['Zend_Pdf_Element_Reference'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Reference.php';
         Yii::$classMap['Zend_Pdf_Element_Array'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/Array.php';
         Yii::$classMap['Zend_Pdf_Element_String'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/String.php';
         Yii::$classMap['Zend_Pdf_Element_String_Binary'] = $yiiBasepath . '/vendor/Zend/Pdf/Element/String/Binary.php';
         Yii::$classMap['Zend_Pdf_Trailer'] = $yiiBasepath . '/vendor/Zend/Pdf/Trailer.php';
         Yii::$classMap['Zend_Pdf_Trailer_Keeper'] = $yiiBasepath . '/vendor/Zend/Pdf/Trailer/Keeper.php';
         $pdf = \Farit_Pdf::load($file->getFullFilePath());
         if (file_exists($cerfile)) {
             $certificate = file_get_contents($cerfile);
             if (empty($certificate)) {
                 throw new \Exception('Cannot open the certificate file');
             }
             $pdf->attachDigitalCertificate($certificate, $configCertpasswd);
             $docfile = $pdf->render();
             $doc_file = new Files();
             $doc_file->name = $name;
             $doc_file->path = "docs/";
             $doc_file->parent_type = get_class($model);
             $doc_file->parent_id = $model->id;
             $doc_file->public = 1;
             $doc_file->hidden = 0;
             $doc_file->save();
             $doc_file->writeFile($docfile);
         } else {
             $link = "";
             $text = Yii::t('app', "Error! <br />\nIt is not possible to create a digitally signed PDF file and/or send it by mail without having certificate file located at current users' configuration page.\nYou should make a certificate file with third party software and import it through 'certificate file' field, separately for each user, within configuration zone of the user. You also should input the password for the certificate file in 'password for digital signature certificate' field in the above mentioned user configuration page.\nYou can find instructions for making self signed certificate file with Acrobat reader (One of the options. There are many applications able to make such a certificate out there)  here: ");
             throw new \Exception($text);
             //Yii::$app->end();
         }
     }
     return $doc_file;
 }
Пример #13
0
echo Yii::t('app', 'Fax');
?>
: <?php 
echo Linet3Helper::getSetting('company.fax');
?>
<br />
            <?php 
echo Linet3Helper::getSetting('company.website');
?>
<br />

            <?php 
echo Yii::t('app', 'VAT No.');
?>
: <?php 
echo Linet3Helper::getSetting('company.vat.id');
?>
<br />
        </div>


        <div  class="logo">
            <?php 
if (Linet3Helper::hasLogo()) {
    echo yii\helpers\Html::img(Linet3Helper::getLogo(), ['class' => 'logo']);
}
?>
        </div>
    </div>

    <hr class="lineHR" />
Пример #14
0
 private function stock($item_id, $qty)
 {
     if (\app\helpers\Linet3Helper::getSetting('company.stock')) {
         // remove from stock.
         $stockAction = $this->docType->stockAction;
         if ($stockAction) {
             if ($this->docType->stockSwitch) {
                 //if has check box
                 if (!$this->stockSwitch) {
                     //if not checked
                     return;
                 }
             }
             $account_id = \app\models\User::getWarehouse($this->owner);
             $oppt_account_id = $this->account_id;
             if ((int) $this->oppt_account_id != 0) {
                 if ($this->doctype == 15) {
                     //only if transfer //mybe shuld be only if oppt_account_type==8 wherehouse
                     $account_id = $this->account_id;
                     $oppt_account_id = $this->oppt_account_id;
                 }
             }
             return stockAction::newTransaction($this->id, $account_id, $oppt_account_id, $item_id, $qty * $stockAction);
         }
     }
     return false;
 }
Пример #15
0
 public function pay()
 {
     $this->dates();
     $this->payvat_acc = \app\helpers\Linet3Helper::getSetting('company.acc.payvat');
     $date = $this->to_date;
     $cur = \app\helpers\Linet3Helper::getSetting('company.cur');
     $owner = Yii::$app->user->id;
     $line = 1;
     $accout = new Transactions();
     $accout->account_id = $this->selvat_acc;
     $accout->type = 6;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'vat') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->selvat_total * -1.0;
     $line++;
     $num = $accout->save();
     $accout = new Transactions();
     $accout->account_id = $this->payvat_acc;
     $accout->type = 6;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'vat') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->selvat_total;
     $line++;
     $accout->save();
     $accout = new Transactions();
     $accout->account_id = $this->buyvat_acc;
     $accout->type = 6;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'vat') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->buyvat_total;
     $line++;
     $accout->save();
     $accout = new Transactions();
     $accout->account_id = $this->payvat_acc;
     $accout->type = 6;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'vat') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->buyvat_total * -1.0;
     $line++;
     $accout->save();
     $accout = new Transactions();
     $accout->account_id = $this->assetvat_acc;
     $accout->type = 6;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'vat') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->assetvat_total;
     $line++;
     $accout->save();
     $accout = new Transactions();
     $accout->account_id = $this->payvat_acc;
     $accout->type = 6;
     $accout->num = $num;
     //$accout->refnum1 = $this->from_date;
     //$accout->refnum2 = $this->to_date;
     $accout->valuedate = $date;
     $accout->details = Yii::t('app', 'vat') . " " . $this->from_month . "-" . $this->to_month . "/" . $this->year;
     $accout->currency_id = $cur;
     $accout->owner_id = $owner;
     $accout->linenum = $line;
     $accout->sum = $this->assetvat_total * -1.0;
     $line++;
     $accout->save();
     //$s = $this->selvat_total * -1.0;
     //$tnum = Transaction(0, VAT, SELLVAT, $ref1, $ref2, $date, _('VAT'), $s);
     //$tnum = Transaction($tnum, VAT, PAYVAT, $ref1, $ref2, $date, _('VAT'), $sellvat);
     //$b = $this->buyvat_total * -1.0;
     //$tnum = Transaction(0, VAT, BUYVAT, $ref1, $ref2, $date, _('VAT'), $buyvat);
     //$tnum = Transaction($tnum, VAT, PAYVAT, $ref1, $ref2, $date, _('VAT'), $b);
     //$a = $this->assetvat_total * -1.0;
     //$tnum = Transaction(0, VAT, ASSETVAT, $ref1, $ref2, $date, _('VAT'), $assetvat);
     //$tnum = Transaction($tnum, VAT, PAYVAT, $ref1, $ref2, $date, _('VAT'), $a);
 }
Пример #16
0
?>
">
            <?php 
NavBar::end();
?>
            <div class="row">
                <div id='sidebar' class="col-md-2">
                    <a class='block' href="<?php 
echo yii\helpers\BaseUrl::base() . '/settings/dashboard';
?>
">
                        <?php 
if (\app\helpers\Linet3Helper::hasLogo()) {
    echo Html::img(\app\helpers\Linet3Helper::getLogo(), ['width' => '100px']);
} else {
    echo Html::tag('h7', \app\helpers\Linet3Helper::getSetting('company.name'));
}
?>
                        
                        <!--<span class="label user-label">16</span>-->
                    </a>



                    <div class="media-body hidden-tablet">
                        <!--<h5 class="media-heading"><?php 
//echo Yii::$app->user->fname . " " . Yii::app()->user->lname;
?>
</h5>-->
                        <ul class="unstyled user-info">
                            <li>
Пример #17
0
echo app\widgets\GridView::widget(array('id' => 'profloss-grid', 'dataProvider' => $model->docsTable(), 'columns' => array(array('header' => Yii::t('app', 'ID'), 'attribute' => 'id'), array('header' => Yii::t('app', 'Name'), 'attribute' => 'name'), array('header' => Yii::t('app', 'Count'), 'attribute' => 'count'), array('header' => Yii::t('app', 'Sum'), 'attribute' => 'sum'))));
//*/
?>
    </div>

    <p><?php 
echo Yii::t('app', 'Data extracted through');
?>
: Linet <?php 
echo \app\helpers\Linet3Helper::getVersion();
?>
</p>
    <p><?php 
echo Yii::t('app', 'Registration Certificate No.');
?>
: <?php 
echo \app\helpers\Linet3Helper::getSetting('system.auth');
?>
</p>
    <p><?php 
echo Yii::t('app', 'Extraction date and time');
?>
: <?php 
echo Yii::$app->formatter->asDate(time(), app\models\Docs::DATETIME_FORMAT);
?>
</p>
    <br />
</div>
<?php 
app\widgets\MiniForm::end();
$this->registerJs("var baseAddress='" . yii\helpers\BaseUrl::base() . "';" . '$("#printThis").click(function (e) {e.preventDefault();window.print();});', \yii\web\View::POS_READY);
Пример #18
0
 public static function getLogo()
 {
     if (!\app\helpers\Linet3Helper::isConsole()) {
         return \Yii::$app->urlManager->createAbsoluteUrl("/site/download/" . Linet3Helper::getSetting('company.logo'));
         //$base . ;
     } else {
         //console
         $download = \app\models\Download::findOne(["id" => Linet3Helper::getSetting('company.logo')]);
         $id = (int) $download->file_id;
         $logo = \app\models\Files::findOne($id);
         return $logo->getFullFilePath();
     }
 }
Пример #19
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return DatabasesPerm the static model class
  */
 public static function buildUserMenu($settings = [])
 {
     if (Yii::$app->user->isGuest) {
         return array(array('label' => Yii::t('app', 'Login'), 'url' => array('/site/login'), 'visible' => Yii::$app->user->isGuest));
     }
     $settings['company.doublebook'] = \app\helpers\Linet3Helper::getSetting('company.doublebook');
     return Menu::buildMenu(0, $settings);
 }
Пример #20
0
 function hasCert()
 {
     $configPath = \app\helpers\Linet3Helper::getSetting("company.path");
     return file_exists($this->getCertFilePath());
 }
Пример #21
0
 public function beforeSave($insert)
 {
     $this->num = $this->newNum();
     if ($this->reg_date == null) {
         $this->reg_date = date("Y-m-d H:i:s");
     }
     $cur = \app\helpers\Linet3Helper::getSetting('company.cur');
     $acc = Accounts::findOne($this->account_id);
     if ($acc === null) {
         $acccur = $this->currency_id;
     } else {
         $acccur = $acc->currency_id;
     }
     if ($this->currency_id == '') {
         $this->currency_id = $cur;
         $this->sum = $this->leadsum;
     }
     //leadsum
     if ($cur == $this->currency_id) {
         $this->leadsum = $this->sum;
     } else {
         $rate = Currates::GetRate($this->currency_id, $this->valuedate);
         $this->leadsum = $this->sum * $rate;
     }
     //set sum accourding to acc
     if (!isset($this->sum)) {
         //adam need to dubl chk
         if ($this->currency_id != $acccur) {
             $this->currency_id = $acccur;
             $rate = Currates::GetRate($acccur, $this->valuedate);
             if ($rate == 0) {
                 throw new \Exception(Yii::t('app', 'The rate for') . $this->currency_id . Yii::t('app', 'is invalid'));
             }
             $this->sum = $this->leadsum / $rate;
         }
     }
     //secsum
     $seccur = \app\helpers\Linet3Helper::getSetting('company.seccur');
     //$seccur = Yii::$app->user->settings['company.seccur'];
     if ($seccur != '') {
         if ($seccur == $this->currency_id) {
             $this->secsum = $this->sum;
         } else {
             $rate = Currates::GetRate($this->currency_id, $this->valuedate);
             if ($rate == 0) {
                 throw new \Exception(Yii::t('app', 'The sec rate for') . $seccur . $this->currency_id . Yii::t('app', 'is invalid'));
             }
             $this->secsum = $this->leadsum / $rate;
         }
     }
     return true;
 }
Пример #22
0
 protected function openfrmtFieldStr($field, $line, $begin = null, $end = null)
 {
     //,
     $value = "";
     if ($value == '' && $field->export != 'NA') {
         $value = $field->export;
     }
     if ($field->export == "file.line") {
         $value = $line;
     }
     if ($field->export == "company.vatnum") {
         $value = \app\helpers\Linet3Helper::getSetting('company.vat.id');
     }
     if (strpos($field->export, "this.") === 0) {
         if (isset($this->{str_replace("this.", "", $field->export)})) {
             $value = $this->{str_replace("this.", "", $field->export)};
         }
     }
     if (strpos($field->export, "system.") === 0) {
         $value = \app\helpers\Linet3Helper::getSetting($field->export);
     }
     if (strpos($field->export, "func.") === 0) {
         $value = $this->{str_replace("func.", "", $field->export)}();
     }
     if (strpos($field->export, "limit.") === 0) {
         $value = $this->{str_replace("limit.", "", $field->export)}($begin, $end);
     }
     if ($field->export == "start") {
         $value = $begin;
     }
     if ($field->export == "end") {
         $value = $end;
     }
     /*         * **************************************************************************************************** */
     $template = "%0" . $field->size . "d";
     if ($field->type == 's') {
         $template = "% " . $field->size . "s";
     }
     if ($field->type == 'n') {
         $template = "%0" . $field->size . "d";
     }
     if ($field->type == 'date') {
         //date
         return $this->readOFDate($value);
     }
     if ($field->type == 'hour') {
         //hour
         //$phpdbdatetime = Yii::$app->locale->getDateFormat('yiidatetime'); //phpdbdatetime
         return $this->readOFTime($value);
     }
     if ($field->type == '99') {
         //v99
         $template = "%0" . $field->size . "d";
         $value = round($value * 100);
         if ($value < 0) {
             $value = $value * -1;
         }
         return sprintf($template, $value);
     }
     if ($field->type == 'v99') {
         //v99
         $template = "%0" . ($field->size - 1) . "d";
         $value = round($value * 100);
         if ($value >= 0) {
             $sign = "+";
         } else {
             $sign = "-";
             $value = $value * -1;
         }
         return $sign . sprintf($template, $value);
     }
     if ($field->type == 'v9999') {
         //v9999
         $template = "%0" . ($field->size - 1) . "d";
         $value = round($value * 10000);
         if ($value >= 0) {
             $sign = "+";
         } else {
             $sign = "-";
             $value = $value * -1;
         }
         return $sign . sprintf($template, $value);
     }
     //ini_set('mbstring.substitute_character', "none");
     //$value= mb_convert_encoding($value, 'UTF-8', 'UTF-8');
     $value = htmlentities($value);
     $value = str_replace("&amp;", "&", $value);
     $value = @iconv("UTF-8", "CP1255", $value);
     //$value=mb_convert_encoding($value, "windows-1255",'utf-8');
     $value = substr($value, 0, $field->size);
     return sprintf($template, $value);
 }
Пример #23
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return Company the static model class
  */
 public function getName()
 {
     $this->select($this->id);
     //ettings::refresh();
     $name = \app\helpers\Linet3Helper::getSetting('company.name');
     return $name;
 }