// Add to entry_invoiced
     mysql_query("INSERT INTO `entry_invoiced` (`entry_id` , `invoiced_id`) VALUES ('" . $entry['entry_id'] . "', '" . $invoiced_id . "');");
     // Updating invoice status
     mysql_query("UPDATE `entry` " . "SET " . "`invoice_status` = '3', " . "`user_last_edit` = '" . $login['user_id'] . "', " . "`time_last_edit` = '" . time() . "', " . "`rev_num` = '{$rev_num}', " . "`invoice_exported_time` = '" . time() . "' " . " WHERE `entry_id` = '" . $entry['entry_id'] . "' LIMIT 1 ;");
     $log_data = array();
     if (!newEntryLog($entry['entry_id'], 'edit', 'invoice_exported', $rev_num, $log_data)) {
     }
     if (is_null($from) || $from > $entry['time_start']) {
         $from = $entry['time_start'];
     }
     if (is_null($to) || $to < $entry['time_end']) {
         $to = $entry['time_end'];
     }
     // Generate PDF data
     $smarty = new Smarty();
     templateAssignEntry('smarty', $entry);
     templateAssignEntryChanges('smarty', $entry, $entry['rev_num']);
     templateAssignSystemvars('smarty');
     $invoicedata[] = $smarty->fetch('file:fakturagrunnlag.tpl');
 }
 if (count($entries) != 1) {
     $er = 'er';
 } else {
     $er = '';
 }
 $pdffile = 'fakturagrunnlag-' . date('Ymd-His') . '-' . count($entries) . '_booking' . $er . '.pdf';
 require_once "libs/dompdf/dompdf_config.inc.php";
 $dompdf = new DOMPDF();
 $dompdf->set_paper('A4');
 $dompdf->load_html(implode($invoicedata));
 $dompdf->render();
示例#2
0
function exchangesync_syncItems($cal, $user, $user_id, $entries_sync)
{
    global $alert_admin, $alerts;
    global $systemurl;
    global $entryObj;
    global $created_items, $deleted_items;
    // "Returns"
    global $area;
    // Build where statement for query and add items that needs to be created
    $entries_new = array();
    $delete_where = array();
    foreach ($entries_sync as $entry_id => $entry) {
        // Only create new if the user is still assigned to entry
        if (isset($entry['user_assigned'][$user_id])) {
            //$entry = getEntry($entry['entry_id']); // Need more information
            templateAssignEntry('entryObj', $entry);
            $rooms = $entryObj->room . ' (' . $area[$entry['area_id']] . ')';
            // Add the entry to list of items
            $i = $cal->createCalendarItems_addItem(utf8_encode($entryObj->entry_name), exchangesync_getEntryCalendarDescription($systemurl, $entryObj), date('c', $entryObj->time_start), date('c', $entryObj->time_end), array('ReminderIsSet' => false, 'Location' => utf8_encode($rooms)), $user['user_ews_sync_email']);
            $entries_new[$i] = $entry['entry_id'];
        }
        // Delete this entry for this user
        $delete_where[] = '(`entry_id` = \'' . $entry_id . '\' && `user_id` = \'' . $user_id . '\')';
    }
    // Delete in Exchange
    $Q_sync = mysql_query("select * from `entry_exchangesync`\n\t\tWHERE " . implode(' || ', $delete_where));
    $deleted_items = array();
    while ($R_sync = mysql_fetch_assoc($Q_sync)) {
        try {
            $deleted_item = $cal->deleteItem($R_sync['exchange_id']);
            $deleted_items[$R_sync['entry_id']] = $deleted_item;
            printout($R_sync['entry_id'] . ' deleted');
        } catch (Exception $e) {
            printout('Exception - deleteItem - ' . $R_sync['entry_id'] . ': ' . $e->getMessage());
            $alert_admin = true;
            $alerts[] = 'deleteItem exception';
        }
    }
    // Delete all the exchangesync data
    $Q_sync = mysql_query("delete from `entry_exchangesync`\n\t\tWHERE " . implode(' || ', $delete_where));
    printout_mysqlerror();
    // Create the new items
    $created_items = array();
    try {
        if (count($entries_new)) {
            $created_items = $cal->createCalendarItems();
        } else {
            printout('No calendar items to be created');
        }
    } catch (Exception $e) {
        printout('Exception - createCalendarItems: ' . $e->getMessage() . '<br />');
        $alert_admin = true;
        $alerts[] = 'createCalendarItems exception: ' . $e->getMessage();
    }
    foreach ($created_items as $i => $ids) {
        if (!is_null($ids['Id'])) {
            $entry = $entries_sync[$entries_new[$i]];
            printout($entries_new[$i] . ' created.');
            // Inserting in sync
            mysql_query("INSERT INTO `entry_exchangesync` (\n\t\t\t\t`entry_id` ,\n\t\t\t\t`exchange_id` ,\n\t\t\t\t`exchange_changekey`,\n\t\t\t\t`user_id`,\n\t\t\t\t`entry_rev`,\n\t\t\t\t`sync_from`,\n\t\t\t\t`sync_to`\n\t\t\t)\n\t\t\tVALUES (\n\t\t\t\t'" . $entry['entry_id'] . "' , \n\t\t\t\t'" . $ids['Id'] . "', \n\t\t\t\t'" . $ids['ChangeKey'] . "',\n\t\t\t\t'" . $user_id . "',\n\t\t\t\t'" . $entry['rev_num'] . "',\n\t\t\t\t'" . $entry['time_start'] . "',\n\t\t\t\t'" . $entry['time_end'] . "'\n\t\t\t);");
            printout_mysqlerror();
        } else {
            if ($ids['ResponseMessage']->ResponseCode == 'ErrorCreateItemAccessDenied') {
                // Alert admin, alert user and disable sync
                emailSend($user_id, 'Ikke tilgang til kalender', exchangesync_getUsermsgAccessDenied($systemurl));
                mysql_query("UPDATE `users` SET `user_ews_sync` = '0' WHERE `user_id` =" . $user_id);
                printout($entries_new[$i] . ' not created. User ' . $user_id . ' has access denied error when creating items. Has disabled the sync of this user. Message from Exchange: ' . $ids['ResponseMessage']->MessageText);
                $alert_admin = true;
                $alerts[] = $entries_new[$i] . ' not created. User ' . $user_id . ' has access denied error when creating items. Has disabled the sync of this user. Message from Exchange: ' . $ids['ResponseMessage']->MessageText;
            } else {
                // Unknown error, alert admin
                printout($entries_new[$i] . ' not created: ' . print_r($ids['ResponseMessage'], true));
                $alert_admin = true;
                $alerts[] = $entries_new[$i] . ' not created. Message from Exchange: ' . $ids['ResponseMessage']->MessageText;
            }
        }
    }
}
示例#3
0
function emailSendEntryUndeleted($entry, $user_id)
{
    global $smarty;
    if (!isUserDeactivated($user_id)) {
        $smarty = new Smarty();
        templateAssignEntry('smarty', $entry);
        templateAssignSystemvars('smarty');
        $message = $smarty->fetch('file:mail-entry-undeleted.tpl');
        $subject = "[booking]" . $entry['entry_id'] . ' ' . date('d.m.Y', $entry['time_start']) . ' Gjenopprettet - ' . $entry['entry_name'];
        emailSend($user_id, $subject, $message);
    }
}
示例#4
0
	'BEGIN:STANDARD'.chr(10).
		'DTSTART:16011028T030000'.chr(10).
		'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10'.chr(10).
		'TZOFFSETFROM:+0200'.chr(10).
		'TZOFFSETTO:+0100'.chr(10).
	'END:STANDARD'.chr(10).
	'BEGIN:DAYLIGHT'.chr(10).
		'DTSTART:16010325T020000'.chr(10).
		'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3'.chr(10).
		'TZOFFSETFROM:+0100'.chr(10).
		'TZOFFSETTO:+0200'.chr(10).
	'END:DAYLIGHT'.chr(10).
'END:VTIMEZONE'.chr(10);*/
echo 'BEGIN:VTIMEZONE' . chr(10) . 'TZID:Europe/Oslo' . chr(10) . 'BEGIN:DAYLIGHT' . chr(10) . 'TZOFFSETFROM:+0100' . chr(10) . 'TZOFFSETTO:+0200' . chr(10) . 'DTSTART:19810329T020000' . chr(10) . 'RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU' . chr(10) . 'TZNAME:CEST' . chr(10) . 'END:DAYLIGHT' . chr(10) . 'BEGIN:STANDARD' . chr(10) . 'TZOFFSETFROM:+0200' . chr(10) . 'TZOFFSETTO:+0100' . chr(10) . 'DTSTART:19961027T030000' . chr(10) . 'RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU' . chr(10) . 'TZNAME:CET' . chr(10) . 'END:STANDARD' . chr(10) . 'END:VTIMEZONE' . chr(10);
$entryObj = new EntryTemplate();
while ($R = mysql_fetch_assoc($Q)) {
    $entry_array = getEntry($R['entry_id']);
    templateAssignEntry('entryObj', $entry_array);
    echo 'BEGIN:VEVENT' . chr(10) . 'SEQUENCE:' . $entryObj->rev_num . chr(10) . 'TRANSP:TRANSPARENT' . chr(10) . 'UID:JMBOOKING-' . $entryObj->entry_id . '-' . time() . chr(10) . 'DTSTART;TZID=Europe/Oslo:' . date('Ymd', $entryObj->time_start) . 'T' . date('His', $entryObj->time_start) . chr(10) . 'DTEND;TZID=Europe/Oslo:' . date('Ymd', $entryObj->time_end) . 'T' . date('His', $entryObj->time_end) . chr(10) . 'CREATED;TZID=Europe/Oslo:' . date('Ymd', $entryObj->time_created) . 'T' . date('His', $entryObj->time_created) . chr(10) . 'DTSTAMP;TZID=Europe/Oslo:' . date('Ymd') . 'T' . date('His') . chr(10);
    //echo date('Y-m-d H:i', strtotime('2008-10-09 08:55 GMT'));
    /*
    $days = 
    echo 'DURATION:P0DT0H0M'.($entryObj->time_end - $entryObj->time_start).chr(10);
    */
    echo 'SUMMARY:' . utf8_encode(htmlspecialchars_decode($entryObj->entry_name, ENT_QUOTES)) . chr(10) . 'DESCRIPTION:' . $systemurl . '/entry.php?entry_id=' . $entryObj->entry_id . ' \\n' . utf8_encode('BID: ' . $entryObj->entry_id) . '\\n' . utf8_encode('Type: ' . $entryObj->entry_type) . '\\n' . utf8_encode('Kunde: ' . $entryObj->customer_name) . '\\n' . utf8_encode('Vert(er): ' . $entryObj->user_assigned_names) . '\\n' . utf8_encode('Antall voksne: ' . $entryObj->num_person_adult) . '\\n' . utf8_encode('Antall barn: ' . $entryObj->num_person_child) . '\\n';
    if ($entryObj->program_id_name != '') {
        echo utf8_encode('Fast program: ' . $entryObj->program_id_name) . '\\n';
    }
    echo '\\n' . utf8_encode('Programbeskrivelse:\\n' . str_replace("\n", '\\n', str_replace("\r", '', htmlspecialchars_decode($entryObj->program_description, ENT_QUOTES)))) . '\\n' . chr(10) . 'LOCATION:' . utf8_encode(implode(', ', $entryObj->rooms)) . ' (' . $entryObj->area . ')' . chr(10) . 'END:VEVENT' . chr(10);
}
echo 'END:VCALENDAR' . chr(10);
示例#5
0
function emailSendEntryUserDeleted($entry, $rev_num, $user_id)
{
    global $smarty;
    $smarty = new Smarty();
    templateAssignEntry('smarty', $entry);
    templateAssignSystemvars('smarty');
    templateAssignEntryChanges('smarty', $entry, $rev_num);
    $message = $smarty->fetch('file:mail-entry-userdeleted.tpl');
    $subject = "[booking]" . $entry['entry_id'] . ' ' . date('d.m.Y', $entry['time_start']) . ' Ikke lenger vert';
    emailSend($user_id, $subject, $message);
}