1. Список говнокодов пользователя DirtyG

    Всего: 1

  2. PHP / Говнокод #16027

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    $sql_color =
    "IF(PsaleCharge.payed = " . TSALE_CONTRACTOR_INIT . ", 'red', IF(PsaleCharge.payed = " . TSALE_CONTRACTOR_PARTIAL . ", 'silver', 'green'))";
    
    $sql_title =
    "IF(PsaleCharge.payed = " . TSALE_CONTRACTOR_INIT . ", 'Не оплачено', IF(PsaleCharge.payed = " . TSALE_CONTRACTOR_PARTIAL . ", 'Оплачено частично', 'Оплачено'))";
    
    if($allow_pay) {
    	$sql_allow_pay = "";
    } else {
    	$sql_allow_pay = "OR TRUE";
    }
    
    $sql_contractor_name =
    "GROUP_CONCAT(" .
    "'<tr>\r\n<td>', " .
    "IF(PsaleCharge.tcontractor_id IS NULL, " .
    "IF(PsaleCharge.recipient IS NULL OR PsaleCharge.recipient = '', '', CONCAT(PsaleCharge.recipient, '&nbsp;')), " .
    "CONCAT('<a href=\"../tcontractors/view?id=', Tcontractor.id, '\" target=\"_blank\">', HTMLSPECIALCHARS(Tcontractor.company), '</a>&nbsp;')" .
    "), " .
    "'</td>\r\n<td style=\'text-align:right;\'>', " .
    
    "IF(Psale.status = " . PSALE_STATUS_CLOSE . " $sql_allow_pay, CONCAT('<span style=\'color:', $sql_color, ';\' title=\'', $sql_title, '\'>', PsaleCharge.amount, '</span>'), " .
    
    "CONCAT(" .
    "'<a style=\'color:', $sql_color, ';\' title=\'', $sql_title, '\' href=\'#\' onclick=\'onPsaleChargeEdit(', PsaleCharge.id, ', ', PsaleCharge.psale_id,  ', false); return false;\'>', " .
    "PsaleCharge.amount, " .
    "'</a>'" .
    ")), " .
    
    "'</td>\r\n</tr>\r\n'" .
    "SEPARATOR ' ')";
    
    $sql_contractors =
    "SELECT $sql_contractor_name " .
    "FROM psale_charges PsaleCharge " .
    "LEFT JOIN tcontractors Tcontractor ON PsaleCharge.tcontractor_id = Tcontractor.id " .
    "WHERE PsaleCharge.psale_id = Psale.id ";

    Формируем разметку в SQL-запросе...

    DirtyG, 21 Мая 2014

    Комментарии (4)