Esempio n. 1
0
 public function prepare()
 {
     $notification = new Notification($this->curpage, $this->db, $this->config);
     $notification->prepare();
     $mainToggle = '';
     $tasksToggle = '';
     $usersToggle = '';
     $serversToggle = '';
     $storeToggle = '';
     $settingsToggle = '';
     $route = getroute();
     if ($route == '') {
         $mainToggle = 'active';
     }
     if ($route == 'servers' || strpos('##' . $route, 'servers/')) {
         $serversToggle = 'active';
     } elseif ($route == 'tasks' || strpos('##' . $route, 'tasks/')) {
         $tasksToggle = 'active';
     }
     if ($route == 'users' || strpos('##' . $route, 'users/')) {
         $usersToggle = 'active';
     }
     if ($route == 'store' || strpos('##' . $route, 'store/')) {
         $storeToggle = 'active';
     }
     if ($route == 'settings' || strpos('##' . $route, 'settings/')) {
         $settingsToggle = 'active';
     }
     $this->data['mainToggle'] = $mainToggle;
     $this->data['tasksToggle'] = $tasksToggle;
     $this->data['usersToggle'] = $usersToggle;
     $this->data['serversToggle'] = $serversToggle;
     $this->data['storeToggle'] = $storeToggle;
     $this->data['settingsToggle'] = $settingsToggle;
     $this->data['notification'] = $notification->show();
 }
Esempio n. 2
0
	function sendUpdateNotification($activities = array()){
		$notif = new Notification();
		$params = $this->getNotificationParams($activities);
		if(!isset($params['project_ccs']) || empty($params['project_ccs']))
			return TRUE;
			
		if($notif->getByName('ProjectUpdated') === FALSE){
			$this->error = "SI_Project::update() : ".$notif->getLastError()."\n";
			return FALSE;
		}
		if($notif->prepare($params) === FALSE){
			$this->error = "SI_Project::update() : ".$notif->getLastError()."\n";
			return FALSE;
		}
		if($notif->send() === FALSE){
			$this->error = "SI_Project::update() : ".$notif->getLastError()."\n";
			return FALSE;
		}

		return TRUE;
	}
Esempio n. 3
0
	function sendEmail($notification = 'InvoiceEmail'){
		$notif = new Notification();
		$params = $this->getNotificationParams();
//		if(!isset($params['invoice_emails']) || empty($params['invoice_emails']))
//			return TRUE;
			
		if($notif->getByName($notification) === FALSE){
			$this->error = "SI_Invoice::sendEmail() : ".$notif->getLastError()."\n";
			return FALSE;
		}
		if($notif->prepare($params) === FALSE){
			$this->error = "SI_Invoice::sendEmail() : ".$notif->getLastError()."\n";
			return FALSE;
		}
		
		// Setup attachment
		$pdf_file = $this->getPDF();
		if($pdf_file === FALSE)
			return FALSE;
			
		$my_company = SureInvoice::getMyCompany();
		$filename = 'invoice_'.$this->id.'.pdf';
		if(!empty($my_company->name)){
			$normalized_name = str_replace(array(',','.',' ',"\t","'",'"'), '_', $my_company->name);
			$filename = $normalized_name.'_'.$this->id.'.pdf';
		}
		$attachments[0]['data'] = $pdf_file;
		$attachments[0]['name'] = $filename;
		$attachments[0]['type'] = 'application/pdf';
		$attachments[0]['encoding'] = 'base64';
		if($notif->send($attachments) === FALSE){
			$this->error = "SI_Invoice::sendEmail() : ".$notif->getLastError()."\n";
			return FALSE;
		}

		// Update sent_ts
		$this->sent_ts = time();
		if($this->update() === FALSE){
			$this->error = "SI_Invoice::sendEmail(): Email sent, error updating sent timestamp: ".$this->getLastError();
			return FALSE;	
		}
		
		return TRUE;
	}