function content()
{
    // get object
    $training = api_moduleDiary_training($_GET['idTraining']);
    //build training form
    $training_form = new str_form("submit.php?act=training_save&idTraining=" . $training->id, "post", "training_edit");
    $training_form->addField("radio", "sport", api_text("module-diary_edit-ff-sport"), NULL, "inline");
    $training_form->addFieldOption("R", api_text("module-diary_edit-fo-sport-run"), !$training->id || "R" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("S", api_text("module-diary_edit-fo-sport-swim"), "S" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("B", api_text("module-diary_edit-fo-sport-bike"), "B" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("T", api_text("module-diary_edit-fo-sport-trail"), "T" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("W", api_text("module-diary_edit-fo-sport-snowshoes"), "W" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("N", api_text("module-diary_edit-fo-sport-rest"), "N" == $training->sport ? TRUE : FALSE);
    $training_form->addField("radio", "sort", api_text("module-diary_edit-ff-sort"), NULL, "inline");
    $training_form->addFieldOption("S", api_text("module-diary_edit-fo-sort-slow"), !$training->id || "S" == $training->sort ? TRUE : FALSE);
    $training_form->addFieldOption("L", api_text("module-diary_edit-fo-sort-long"), "L" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("F", api_text("module-diary_edit-fo-sort-fast"), "F" == $training->sport ? TRUE : FALSE);
    $training_form->addFieldOption("N", api_text("module-diary_edit-fo-sort-rest"), "N" == $training->sport ? TRUE : FALSE);
    $training_form->addField("text", "time", api_text("module-diary_edit-ff-time"), $training->time, "input-medium", api_text("module-diary_edit-ff-time-placeholder"));
    $training_form->addField("text", "distance", api_text("module-diary_edit-ff-distance"), $training->distance, "input-small", api_text("module-diary_edit-ff-distance-placeholder"));
    $training_form->addField("text", "description", api_text("module-diary_edit-ff-description"), $training->description, "input-large", api_text("module-diary_edit-ff-description-placeholder"));
    $training_form->addField("date", "datetraining", api_text("module-diary_edit-ff-datetraining"), $training->datetraining, "input-small");
    // controls
    $training_form->addControl("submit", api_text("module-diary_edit-fc-submit"));
    if ($training->id) {
        $training_form->addControl("button", api_text("module-diary_edit-fc-cancel"), NULL, "module-training_view.php?idTraining=" . $training->id);
    } else {
        $training_form->addControl("button", api_text("module-diary_edit-fc-cancel"), NULL, "module-training_list.php");
    }
    // show training form
    $training_form->render();
    // debug
    if ($_SESSION["account"]->debug) {
        pre_var_dump($training, "print", "training");
    }
    ?>
<script type="text/javascript">
 $(document).ready(function(){
  // validation
  $("form[name='training_edit']").validate({
   rules:{
    sport:{required:true,minlength:1},
    sort:{required:true,minlength:1}
   },
   submitHandler:function(form){form.submit();}
  });
 });
</script>
<?php 
}
Esempio n. 2
0
/**
 * Training Delete
 */
function training_delete()
{
    // check training edit permission
    if (!api_checkPermission("module-diary", "training_del")) {
        api_die("trainingDenied");
    }
    // get objects
    $training = api_moduleDiary_training($_GET['idTraining']);
    if (!$training->id) {
        exit(header("location: module-diary_list.php?alert=trainingNotFound&alert_class=alert-error"));
    }
    // execute queries
    $GLOBALS['db']->execute("DELETE FROM `module-diary_trainings` WHERE `id`='" . $training->id . "'");
    // log event
    $log = api_log(API_LOG_WARNING, "module-diary", "trainingDeleted", "{logs_module-diary_trainingDeleted|" . $training->sport . "|" . $training->sort . "}", $training->id);
    // redirect
    $alert = "?alert=trainingDeleted&alert_class=alert-warning&idLog=" . $log->id;
    exit(header("location: module-diary_list.php" . $alert));
}
function content()
{
    // get objects
    $training = api_moduleDiary_training($_GET['idTraining']);
    if (!$training->id) {
        echo api_text("trainingNotFound");
        return FALSE;
    }
    // build training dynamic list
    $training_dl = new str_dl("br", "dl-horizontal");
    $training_dl->addElement(api_text("module-diary_view-dt-sport"), $training->sportText);
    $training_dl->addElement(api_text("module-diary_view-dt-sort"), $training->sortText);
    $training_dl->addElement(api_text("module-diary_view-dt-time"), $training->time);
    $training_dl->addElement(api_text("module-diary_view-dt-distance"), $training->distance);
    $training_dl->addElement(api_text("module-diary_view-dt-description"), $training->description);
    $training_dl->addElement(api_text("module-diary_view-dt-datetraining"), $training->datetraining);
    // show address dynamic list
    $training_dl->render();
    // debug
    if ($_SESSION["account"]->debug) {
        pre_var_dump($training, "print", "training");
    }
}
Esempio n. 4
0
<?php

/* -------------------------------------------------------------------------- *\
|* -[ Module-Diary - Template ]------------------------------------------- *|
\* -------------------------------------------------------------------------- */
// include module information file
include "module.inc.php";
// include core api functions
include "../core/api.inc.php";
// load module api and language
api_loadModule();
// print header
$html->header(api_text("module-title"), $module_name);
// get objects
$training = api_moduleDiary_training($_GET['idTraining']);
// build navigation menu
global $navigation;
$navigation = new str_navigation(api_baseName() == "module-diary_list.php" ? TRUE : FALSE);
// filters
if (api_baseName() == "module-diary_list.php") {
    // sport
    $navigation->addFilter("multiselect", "sport", api_text("filter-sport"), array("R" => api_text("filter-run"), "S" => api_text("filter-swim"), "B" => api_text("filter-bike"), "T" => api_text("filter-trail"), "W" => api_text("filter-snowshoes")));
    $navigation->addFilter("multiselect", "sort", api_text("filter-sort"), array("S" => api_text("filter-slow"), "L" => api_text("filter-long"), "F" => api_text("filter-fast")));
    // if not filtered load default filters
    if ($_GET['resetFilters'] || $_GET['filtered'] != 1 && $_SESSION['filters'][api_baseName()]['filtered'] != 1) {
        //include("filters.inc.php");
    }
}
// list
$navigation->addTab(api_text("module-diary-nav-list"), "module-diary_list.php");
if (api_baseName() == "module-diary_list.php") {
Esempio n. 5
0
/**
 * Trainings export
 *
 * @return object $results array
 */
function api_moduleDiary_trainings_export()
{
    // definitions
    $return = new stdClass();
    $return->results = array();
    // generate query
    $query_table = "`module-diary_trainings`";
    // fields
    $query_fields = "*";
    // build query
    $return->query = "SELECT " . $query_fields . " FROM " . $query_table;
    // execute query
    $results = $GLOBALS['db']->query($return->query);
    while ($result = $GLOBALS['db']->fetchNextObject($results)) {
        $return->results[$result->id] = api_moduleDiary_training($result);
        // return objects
        return $return;
    }
}