// ----------------------------------------------------------------------------- // CPIMAgnToDoAdapter::ReadDateFieldsL // (other items were commented in a header) // ----------------------------------------------------------------------------- // void CPIMAgnToDoAdapter::ReadDateFieldsL(MPIMItemData& aData, CCalEntry& aEntry) { JELOG2(EPim); TTime nullTime = Time::NullTTime(); // The Agenda todo entry end field is the due date TTime due(aEntry.EndTimeL().TimeLocalL()); if (due != nullTime) { // Set due to the PIM API specific due date, in this case, the start of date // Note that PIM API uses times as UTC times so the due date must be in // correct format. Previously requested as local time -> do not change TPIMDate pimDueDate(StartOfDay(due)); // Date must be converted UTC time because acquired as local above ConvertTimeL(pimDueDate, EPIMDateUTC); TPIMFieldData dueFieldData(EPIMToDoDue, KPIMAttrNone, pimDueDate); aData.AddValueL(dueFieldData); // Get alarm. Ownership is transferred to the caller. Alarm cannot be set // if the due date is not set because the calculation is done as an offset // from the ToDo due date. CCalAlarm* calAlarm = aEntry.AlarmL(); if (calAlarm) { TTimeIntervalMinutes nativeValue = calAlarm->TimeOffset(); // The alarm is not needed anymore so it can be deleted delete calAlarm; calAlarm = NULL; // Change the time to the start of the due date TTime startOfDayLocal(StartOfDay(due)); // Calculate the difference from the start of due date and start time including // the original alarm offset which was previously read TTimeIntervalMinutes temp(0); User::LeaveIfError(startOfDayLocal.MinutesFrom(due, temp)); // Since it is not possible to substract TTimeIntervalMinutes // from TTime (probably a Symbian error), the difference has // to be calculated using the following way... TInt alarm = (nativeValue.Int() + temp.Int()) * KPIMSecondsInMinute; // Add alarm value to the item TPIMFieldData fieldData(EPIMToDoExtAlarm, EPIMFieldInt, KPIMAttrNone, alarm); // Add value to the PIM item data aData.AddValueL(fieldData); } } // Completion date. If the item has a completion date, the item is then completed // and completed flag is set to true in PIM API. Null time if not crossed out. TTime completed = aEntry.CompletedTimeL().TimeUtcL(); if (completed != nullTime) { TPIMFieldData dateData(EPIMToDoCompletionDate, KPIMAttrNone, completed); aData.AddValueL(dateData); // Note that boolean and integer fields must be identified in the constructor TPIMFieldData flag(EPIMToDoCompleted, EPIMFieldBoolean, KPIMAttrNone, ETrue); aData.AddValueL(flag); } }
void apWorkBench::sCalculateTotalOpen() { // copied and edited from selectPayments.cpp ParameterList params; _vendorgroup->appendValue(params); params.append("voucher", tr("Voucher")); params.append("debitMemo", tr("D/M")); XComboBox *bankaccnt = _payables->findChild<XComboBox*>("_bankaccnt"); if (bankaccnt->isValid()) { q.prepare( "SELECT bankaccnt_curr_id " "FROM bankaccnt " "WHERE (bankaccnt_id=:bankaccnt_id);" ); q.bindValue(":bankaccnt_id", bankaccnt->id()); q.exec(); if (q.first()) params.append("curr_id", q.value("bankaccnt_curr_id").toInt()); else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } } if (_payables->findChild<XComboBox*>("_selectDate")->currentIndex() == 1) params.append("olderDate", _payables->findChild<DLineEdit*>("_onOrBeforeDate")->date()); else if(_payables->findChild<XComboBox*>("_selectDate")->currentIndex() == 2) { params.append("startDate", _payables->findChild<DLineEdit*>("_startDate")->date()); params.append("endDate", _payables->findChild<DLineEdit*>("_endDate")->date()); } MetaSQLQuery due( "SELECT SUM((apopen_amount - apopen_paid - " " COALESCE((SELECT SUM(checkitem_amount + checkitem_discount) " " FROM checkitem, checkhead " " WHERE ((checkitem_checkhead_id=checkhead_id) " " AND (checkitem_apopen_id=apopen_id) " " AND (NOT checkhead_void) " " AND (NOT checkhead_posted)) " " ), 0)) / apopen_curr_rate) AS openamount_base," " SUM(COALESCE(currToBase(apselect_curr_id, apselect_amount," " CURRENT_DATE), 0)) AS selected_base " "FROM vend, apopen" " LEFT OUTER JOIN apselect ON (apselect_apopen_id=apopen_id) " "WHERE ((apopen_open)" " AND (apopen_doctype IN ('V', 'D'))" " AND (apopen_vend_id=vend_id)" "<? if exists(\"vend_id\") ?>" " AND (vend_id=<? value(\"vend_id\") ?>)" "<? elseif exists(\"vendtype_id\") ?>" " AND (vend_vendtype_id=<? value(\"vendtype_id\") ?>)" "<? elseif exists(\"vendtype_pattern\") ?>" " AND (vend_vendtype_id IN (SELECT vendtype_id" " FROM vendtype" " WHERE (vendtype_code ~ <? value(\"vendtype_pattern\") ?>)))" "<? endif ?>" "<? if exists(\"olderDate\") ?>" " AND (apopen_duedate < <? value(\"olderDate\") ?>)" "<? elseif exists(\"startDate\") ?>" " AND (apopen_duedate BETWEEN <? value(\"startDate\") ?> AND <? value(\"endDate\") ?>)" "<? endif ?>" "<? if exists(\"curr_id\") ?>" " AND (apopen_curr_id=<? value(\"curr_id\") ?>)" "<? endif ?>" ");" ); q = due.toQuery(params); if (q.first()) _apopenTotal->setLocalValue(q.value("openamount_base").toDouble()); else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } // copied from unappliedAPCreditMemos and edited MetaSQLQuery cr( "SELECT SUM((apopen_amount - apopen_paid)/ apopen_curr_rate) AS basebalance " "FROM apopen, vend " "WHERE ( (apopen_doctype='C')" " AND (apopen_open)" " AND (apopen_vend_id=vend_id)" "<? if exists(\"vend_id\") ?>" " AND (vend_id=<? value(\"vend_id\") ?>)" "<? elseif exists(\"vendtype_id\") ?>" " AND (vend_vendtype_id=<? value(\"vendtype_id\") ?>)" "<? elseif exists(\"vendtype_pattern\") ?>" " AND (vend_vendtype_id IN (SELECT vendtype_id" " FROM vendtype" " WHERE (vendtype_code ~ <? value(\"vendtype_pattern\") ?>)))" "<? endif ?>" ");"); q = cr.toQuery(params); if (q.first()) { _apopenTotal->setLocalValue(_apopenTotal->localValue() - q.value("basebalance").toDouble()); } else if (q.lastError().type() != QSqlError::NoError) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return; } }