Esempio n. 1
0
 public function actionIndex()
 {
     $session = new CHttpSession();
     $otpr = $stopt = 0;
     if (isset($_POST['input_email']) && $_POST['input_email'] !== '') {
         $model = SegScheduledTours::model()->findByPk($_POST['sid'] * 1);
         //$_POST['sid']*1);
         $tour = SegTourroutes::model()->findByAttributes(array('cityid' => $model->city_id, 'id_tour_categories' => $_POST['tid'] * 1));
         /////
         $starttime = str_replace('00:00', '00', $model->starttime);
         $tourdate = $this->dateEn($model->date);
         if (!empty($model->duration)) {
             $stopt = $model->duration;
         } else {
             $stopt = $tour->standard_duration;
         }
         $stoptime = date("H:i", strtotime($model->date . ' ' . $model->starttime) + $stopt * 60) . ' Uhr';
         $tour_guest = '';
         $tour_name = $model->city_ob->seg_cityname . ' ' . $tour->name;
         ////lang
         $text_lang = $model->language_ob->germanname;
         if (is_null($model->language_id)) {
             $lang = SegLanguagesGuides::model()->with('languages')->findAll('users_id=' . $model->guide1_id);
             $zp = $text_lang = '';
             foreach ($lang as $val) {
                 $text_lang .= $zp . $val->languages->germanname;
                 $zp = ', ';
             }
         }
         ////
         ////point
         $meetingpoint = $tour->meetingpoint_description;
         if (Yii::app()->language == 'en') {
             $meetingpoint = $tour->meetingpoint_description_en;
         }
         $session['city_en'] = $model->city_ob->webadress_en;
         $session['city_name'] = $model->city_ob->seg_cityname;
         if (is_array($_POST['input_email'])) {
             $mailtext = array('city_name' => $model->city_ob->seg_cityname, 'city_en' => $model->city_ob->webadress_en, 'tour_date' => $tourdate, 'tour_starttime' => $starttime, 'tour_stoptime' => $stoptime, 'tour_guest' => $_POST['guest'], 'tour_name' => $tour_name, 'tour_lang' => $text_lang, 'tour_guide_name' => $model->user_ob->guidename, 'tour_guide_tel' => $model->user_ob->contact_ob->phone, 'contact_name' => $_POST['contact_name'], 'contact_street' => $_POST['contact_street'], 'contact_city' => $_POST['contact_city'], 'contact_land' => $_POST['contact_land'], 'contact_tel' => $_POST['contact_tel'], 'contact_email' => $_POST['contact_email'], 'meetingpoint' => $meetingpoint);
             foreach ($_POST['input_email'] as $k => $email) {
                 $msg = $this->renderPartial('tour_mail', $mailtext, TRUE);
                 if ($this->sendMail($email, 'Cherrytours: ' . $tour_name, $msg)) {
                     $otpr++;
                 }
             }
         }
         //$otpr=0;
         $session['text_link'] = 'Einladungen werden nicht gesendet. Fehler-Mail-Server.';
         if ($otpr > 0) {
             $session['text_link'] = 'Bestätigung per Email versendet';
             echo '<meta http-equiv="refresh" content="0">';
             exit;
         }
     }
     $this->render('mail_success', array('text_link' => $session['text_link'], 'city_en' => $session['city_en'], 'city_name' => $session['city_name']));
 }
Esempio n. 2
0
 	public function loadTourroute($id)
	{
		$model=SegTourroutes::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
 public function loadTR($id, $cat)
 {
     $model = SegTourroutes::model()->findByAttributes(array('cityid' => $id, 'id_tour_categories' => $cat));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 4
0
	public function createpdf($sched)
	{
		
		$id_control = Yii::app()->user->id;
            $guide = User::model()->with('contact_ob')->findByPk($id_control);
		$date_format = strtotime($sched->date);
		$date_bd = date('Y-m-d',$date_format);
		$dt =$date_bd.' '.$sched->starttime;
		$tour = SegTourroutes::model()->findByPk($sched->tourroute_id);
		$mails=array();
		$fn='.'; $ln='.';
		if((!is_null($guide->contact_ob['firstname'])) && $guide->contact_ob['firstname']!=''){$fn = $guide->contact_ob['firstname']{0};}else{$fn='0';}
		if((!is_null($guide->contact_ob['surname'])) && $guide->contact_ob['surname']!=''){$ln = $guide->contact_ob['surname']{0};}else{$ln='0';}
		$c = $tour->city['seg_cityname']{0};
		$year = date('y',time());
                $b = $tour->city['seg_cityname']{0};
 		$num=0;
		$criteria_i = new CDbCriteria;
		$criteria_i->condition = 'guide1_id=:guide1_id AND openTour=:openTour';
		$criteria_i->params = array(':guide1_id'=>$id_control,'openTour'=>1);
		$schedall = SegScheduledTours::model()->findAll($criteria_i);
		foreach($schedall as $item){
				$year_item = date('y',$item->date_now);
				if($year_item == $year){
					$num++;
				}
			}
		$num = $num+1;
//		$sched->GN_string = $fn.$ln.$c.'/'.$id_control.'/'.$year.'/'.$num;		
		$sched->GN_string = $fn.$ln.$c.'/'.$year.'/'.$num;		
		$sched->openTour = 1;//create pdf
			//tourroutes
		$criteria_tourroutes = new CDbCriteria;
		$criteria_tourroutes->condition = 'usersid=:usersid AND tourroutes_id=:tourroutes_id';
		$criteria_tourroutes->params = array(':usersid'=>$sched->user_ob->id,'tourroutes_id'=>$tour->id_tour_categories);
		$tourroutes = SegGuidesTourroutes::model()->find($criteria_tourroutes);
		$vat= Yii::app()->db->createCommand("SELECT value from mainoptions where name='Vat'")->queryScalar();
		$firma= Yii::app()->db->createCommand("SELECT value from mainoptions where name='Firma'")->queryScalar();
		$sum_itog=0;
		$sum_bar=0;
		$count_cust=0;
        $max= Yii::app()->db->createCommand("SELECT max(InvoiceNumber) from seg_guidestourinvoices where cityid=".$tour->cityid)->queryScalar();
        $max_i = $max+1;
        foreach ($sched->guidestourinvoices as $invoice) 
       {
            $model=$invoice->guidestourinvoicescustomers;
            $overAllIncome=0;
            $cashIncome=0;
            $count_inv=0;
            $invoice_id =  $invoice->idseg_guidesTourInvoices;
            for($k=0;$k<count($model);$k++){
                $kk=$model[$k]->idseg_guidesTourInvoicesCustomers;
                    if($model[$k]->isPaid == 1)  $count_cust++;
                    $count_inv++;
                }
               $invoice->status = 1;
               $sum_itog += $invoice->overAllIncome;
               $sum_bar += $invoice->cashIncome;
               $invoice->TA_string = 'TA'.$b.$year.'/'.$max_i;
               $invoice->InvoiceNumber =$max_i;
               $invoice->save();
               $tmpname=$this->doPDF($sched, $invoice);
               $mails[]=array($invoice->contact['email'],$tmpname);
        }
		$sum_vat = round($sum_itog*(1-1/($vat/100+1)),2);
		$sum_b_vat = $sum_itog - $sum_vat;
	
		$cifra = $count_cust - $tourroutes->guest_variable;
		if($cifra<=0){$cifra=0;}//turists >
		$gonorar = $tourroutes->base_provision+$cifra*$tourroutes->guestsMinforVariable;//summa gonorar
		$gonorar_vat = $gonorar*(1-1/($vat/100+1));
		$gonorar_vat = number_format($gonorar_vat, 2, '.', ' ');

		$cashnew=new CashboxChangeRequests;
		$cashnew->id_users=$id_control;
		$cashnew->approvedBy=$id_control;
		$cashnew->delta_cash = $sum_bar;
		$datetime = date('Y-m-d H:i:s', time());
		$cashnew->approval_date=$datetime;
		$cashnew->id_type = 1;
		$cashnew->sched_user_id = $sched->idseg_scheduled_tours;
		$cashnew->save();
		$cashnew1 = new CashboxChangeRequests;
		$cashnew1->id_users=$id_control;
		$cashnew1->approvedBy=$id_control;
		$cashnew1->approval_date=$datetime;
		$cashnew1->sched_user_id = $sched->idseg_scheduled_tours;
		$cashnew1->delta_cash = -$gonorar;
		$cashnew1->id_type = 2;
		$cashnew1->save();
            $cashnow=$this->cashsum;
		//************************************PDF CREATE***************************************************//
		//$pdf->SetFont('freeserif', '', 14);
		$printOrders = null;
		$forpdf=array();
		$forpdf['gonorar_vat']=$gonorar_vat;
		$forpdf['firma']=$firma;
		$forpdf['cifra']=$cifra;
		$forpdf['base_provision'] = number_format($tourroutes->base_provision, 2, '.', ' ');
		$forpdf['guestsMinforVariable'] = number_format($tourroutes->guestsMinforVariable, 2, '.', ' ');
		$forpdf['gonorar_zero'] = number_format($gonorar, 2, '.', ' ');
		$forpdf['cashBefore'] = number_format($cashnow, 2, '.', ' '); 
		$forpdf['sum_bar_zero'] = number_format($sum_bar, 2, '.', ' '); 
		$forpdf['cashnow_zero'] = number_format($cashnow-$gonorar+$sum_bar, 2, '.', ' '); 
		$forpdf['delta_cash_zero'] = number_format($sum_bar-$gonorar, 2, '.', ' ');
		$forpdf['cashnow_enter'] = number_format($cashnow+$gonorar-$sum_bar, 2, '.', ' ');
		$name_pdf2=$this->doPDF($sched, $forpdf);
//		var_dump($mails);return false;
		$sched->additional_info2=$name_pdf2;
		$sched->save();
             $message="Dear sirs, \n The invoice from Cherry tours.";
                $subject = "The invoice from Cherry tours";
				foreach ($mails as $value) {
        			$this->sendMail($value[0],$subject,$message, __DIR__.'/../../../../filespdf/'.$value[1].'.pdf');
						unlink(__DIR__.'/../../../../filespdf/'.$value[1].'.pdf');
			}
	        $this->redirect( Yii::app()->createUrl('/filespdf/'.$name_pdf2.'.pdf') );
	}